Document Analysis, RAG Chatbot, and Pinecone Indexing - n8n Workflow

Create a powerful Retrieval-Augmented Generation (RAG) system using a comprehensive n8n workflow. Analyze uploaded files with Llama Parser, index data in Pinecone, and deploy a Gemini-powered chatbot for Q&A.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • AI/ML Developers and Engineers building advanced RAG knowledge bases.

  • Users managing large documentation sets who need automated analysis and retrieval.

  • Businesses seeking to deploy complex, multi-step n8n templates involving vector databases and large language models.

  • Technical writers who require structured, automated summaries of uploaded documents.

Overview

This sophisticated n8n workflow provides a complete solution for taking unstructured document input and transforming it into an interactive, queryable knowledge base. The process is initiated by an n8n trigger (form submission) where users upload files. The workflow leverages LlamaIndex's powerful cloud parser to convert files into structured Markdown. Following this, Google Gemini models perform translation and deep analysis, ensuring the content is clean and well-structured.

Critically, the analyzed content is chunked and vectorized using Mistral Embeddings before being stored in a Pinecone vector database. This indexing process establishes the knowledge base for the second half of the solution: the Retrieval-Augmented Generation (RAG) Chatbot. The user receives an email containing both the analysis summary and a link to the dedicated n8n chatbot interface, allowing immediate, context-aware interaction with their uploaded documents. This complex interaction demonstrates the power of the n8n node ecosystem for end-to-end AI automation.

How it Works

This n8n workflow operates in two distinct, interconnected phases:

Phase 1: Document Processing and Indexing


  1. Initiation: The n8n workflow starts with an 'On form submission' n8n trigger, collecting document files and the user's email address.

  2. File Handling: The 'split the binary item' Code n8n node separates the uploaded files into individual items for processing.

  3. Parsing: Each file is sent to the LlamaIndex Cloud Parsing API via an HTTP Request n8n node, converting it to Markdown.

  4. Status Check & Aggregation: The workflow polls the API for parsing success ('If2' n8n node). The resulting Markdown content is then collected using the 'Aggregate1' n8n node.

  5. AI Analysis: The aggregated Markdown is processed by a 'Translator Agent' (using Google Gemini Chat Model) to handle language diversity, followed by an 'Analyzer Agent' (also using Gemini) for comprehensive structural analysis and cleaning.

  6. Knowledge Base Creation (Vector DB): The analyzed content is converted to a text file ('Convert to File4') then fed to the Langchain Default Data Loader, split into chunks ('Recursive Character Text Splitter'), and vectorized using 'Embeddings Mistral Cloud'. Finally, the data is inserted into the 'Pinecone Vector Store' n8n node.

  7. Notification: The cleaned analysis is converted back to text and emailed to the user via the 'Gmail' n8n node, providing a link to the chatbot interface.

Phase 2: Retrieval-Augmented Generation (RAG) Chatbot


  1. Chat Trigger: The RAG functionality begins with the 'When chat message received' n8n trigger when a user interacts with the public webhook link.

  2. RAG Chain: The user's prompt enters the 'Question and Answer Chain' n8n node, which utilizes a Gemini language model for reasoning.

  3. Context Retrieval: The 'Vector Store Retriever' n8n node searches the connected 'Pinecone Vector Store1' index using Mistral embeddings to find relevant document chunks.

  4. Final Response: The retrieved context and the user's question are synthesized by the LLM. The 'AI Agent1' then rephrases the final answer, ensuring a concise text-only response is returned to the user, completing the RAG cycle for this powerful n8n workflow.

Installation Guide

To deploy this advanced n8n workflow, follow these steps:


  1. Import the n8n Workflow: Copy the provided JSON data and import it into your n8n instance via the 'Workflows' menu, selecting 'New' and 'Import from JSON'.

  2. Set up Credentials: You will need to configure credentials for the following services:

LlamaIndex Cloud: Configure the Bearer Token for the HTTP Request n8n nodes ('Parsing the document' and others) using your LlamaIndex API key.
Google Gemini (or compatible LLM): Configure the Language Model n8n nodes (Google Gemini Chat Model) with your API key.
Pinecone: Configure the 'Pinecone Vector Store' n8n node with your Pinecone index name (samuraichamploo), environment, and API key.
Mistral Cloud: Configure the 'Embeddings Mistral Cloud' n8n node with your Mistral API key.
* Gmail: Set up credentials for the 'Gmail' n8n node to send the final analysis email.

  1. Activate Triggers: Ensure the 'On form submission4' n8n trigger is active to handle document uploads, and that the 'When chat message received' n8n trigger is public and active for the chatbot functionality.

  2. Test: Run the workflow manually once to ensure all API connections are successful and the data flows correctly from the document upload through indexing to the final email delivery. This template requires careful configuration due to its reliance on multiple external services.

Node Details

This n8n workflow utilizes many specialized and custom nodes to achieve complex AI functionality:

On form submission4 (n8n trigger): Initiates the document processing flow, collecting files and the user's contact email.
split the binary item (Code n8n node): A crucial custom script that iterates through the binary data provided by the form trigger and separates the uploaded files for individual processing.
Parsing the document (HTTP Request n8n node): Uploads the file to the LlamaIndex Cloud parsing service using multipart-form-data and Bearer Token authorization.
Google Gemini Chat Model (Langchain n8n node): Multiple instances (e.g., 5, 6, 2, 3) are used throughout the n8n workflow, serving as the core LLM for translation, complex analysis, and generating RAG responses.
Analyzer Agent (AI Agent n8n node): Instructed with detailed system messages to perform comprehensive analysis, structuring, and duplication checks on the parsed document content.
Convert to File (n8n node): Used to convert the final analyzed text into a binary file format, suitable for attaching to the outgoing email via the Gmail n8n node.
Embeddings Mistral Cloud (Langchain n8n node): Responsible for generating high-quality vector representations (embeddings) of the document chunks.
Pinecone Vector Store (Langchain n8n node): Manages the persistent storage and retrieval of vector embeddings into the specified Pinecone index (samuraichamploo).
Recursive Character Text Splitter (Langchain n8n node): Prepares large documents for vector storage by breaking them into optimal, overlapping chunks.
When chat message received (n8n trigger): The webhook n8n trigger for the live chatbot interface, initiating the RAG query process.


  • Question and Answer Chain (Langchain n8n node): The central RAG component that connects the user question, the vector store retriever, and the LLM to generate context-aware answers.

Related n8n Workflows

Free

Nodes: 20 Nodes
Updated: December 26 2025
View all
Created by
pavith
pavith

Featured*