RAG Document QA System with Milvus, Cohere, and GPT-4o - n8n Workflow

Implement a powerful RAG system using this n8n workflow. Automatically index Google Drive PDFs using Cohere embeddings and Milvus, then query documents instantly via an OpenAI-powered n8n agent.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Data engineers and developers seeking robust RAG solutions.
Businesses needing automated, secure document Q&A capabilities.
Users looking for advanced n8n templates utilizing vector databases.
Anyone interested in integrating Cohere, Milvus, and OpenAI within a single n8n workflow environment.

Overview

This sophisticated n8n workflow automates the entire Retrieval Augmented Generation (RAG) pipeline, ensuring your AI agent has instant access to fresh information. The system operates in two distinct, yet interconnected, paths. The first path handles data ingestion: whenever a new PDF is dropped into a specified Google Drive folder, the dedicated n8n trigger fires, processing, chunking, embedding via the Cohere embeddings n8n node, and indexing the content into the Milvus vector database. The second path handles the user query: an interaction with the Chat Trigger initiates the RAG Agent n8n node, which uses the indexed data retrieved from Milvus (using Cohere embeddings for similarity search) to formulate accurate answers using OpenAI's GPT-4o model. This end-to-end n8n workflow is designed for high performance and multilingual support, making it one of the most powerful RAG n8n templates available.

How it Works

This n8n workflow functions through two primary mechanisms: the ingestion pipeline and the query pipeline.

1. Ingestion Pipeline (Data Loading)


  1. Watch New Files (Google Drive Trigger): This n8n trigger constantly monitors a specified Google Drive folder (named 'RAG template') for newly created files.

  2. Download New: The n8n node downloads the file identified by the trigger.

  3. Extract from File: The contents of the downloaded file (configured for PDF extraction) are read.

  4. Set Chunks (Text Splitter): The raw text is split into small, manageable chunks (700 characters with 60 characters overlap) for optimal embedding quality, preparing the data for the Milvus n8n node.

  5. Embeddings Cohere: Each text chunk is converted into a vector embedding using the Cohere model (embed-multilingual-v3.0).

  6. Insert into Milvus: The final embedded vectors and their corresponding source texts are inserted into the designated Milvus collection, completing the knowledge base update.

2. Query Pipeline (RAG Agent)


  1. When chat message received (n8n Trigger): The RAG agent is activated by a user message through this dedicated LangChain chat n8n trigger.

  2. Retrieve from Milvus (Tool): The system first uses Cohere embeddings to vectorize the user's query. The Milvus n8n node is configured as a tool within the agent, performing a similarity search (top K=10) to find the most relevant document chunks.

  3. Memory: The Memory n8n node ensures that the conversation history is maintained during interaction with the agent.

  4. OpenAI 4o: The relevant context retrieved from Milvus, the chat history, and the user's new query are passed to the OpenAI Large Language Model (gpt-4o).

  5. RAG Agent: The central RAG Agent n8n node orchestrates the entire process, utilizing the Milvus retrieval tool and the OpenAI language model to generate a factual, contextually relevant response.

Installation Guide

To successfully deploy this advanced n8n workflow, follow these setup steps:


  1. Import the n8n Workflow: Copy the provided JSON data and import it directly into your n8n instance.

  2. Google Drive Credentials: Configure the 'Watch New Files' and 'Download New' n8n node credentials. Ensure the specified folder ID (15gjDQ...) corresponds to a folder where you will upload PDFs.

  3. Cohere API Credentials: Set up credentials for Cohere (used in both ingestion and retrieval). This must be linked to both 'Embeddings Cohere' n8n nodes.

  4. Milvus Credentials: Set up the Milvus API credentials (e.g., from Zilliz Cloud). Ensure the collection name used in the 'Insert into Milvus' and 'Retrieve from Milvus' n8n node instances is consistent.

  5. OpenAI Credentials: Provide the API key for the 'OpenAI 4o' n8n node.

  6. Activate: Save the n8n workflow and activate both the Google Drive n8n trigger and the Chat Message n8n trigger.

Node Details

Watch New Files (n8n Trigger): A Google Drive n8n trigger that starts the ingestion process whenever a new file is uploaded to the monitored folder. Key setting: triggerOn set to specificFolder.
Extract from File: An n8n node dedicated to parsing the content of the file, specifically configured to handle PDF documents (operation: pdf).
Set Chunks (Text Splitter n8n node): Essential for RAG, this node optimizes text for embedding by splitting documents into chunks of size 700, with an overlap of 60.
Embeddings Cohere: This LangChain n8n node handles the conversion of text into vector embeddings using the high-performance embed-multilingual-v3.0 model.
Insert into Milvus (Vector Store n8n node): The core storage component. This n8n node inserts the Cohere-generated vectors into the Milvus database collection, building the index for the RAG system.
When chat message received (n8n Trigger): A LangChain chat n8n trigger that serves as the entry point for user queries.
Retrieve from Milvus (Vector Store n8n node): Configured in retrieve-as-tool mode, this n8n node executes the similarity search against Milvus, returning the top 10 relevant document chunks to the agent.
OpenAI 4o (Language Model n8n node): Provides the intelligence for generation, using gpt-4o to synthesize the final answer based on the context provided by the retrieval tool and chat history.


  • RAG Agent (LangChain Agent n8n node): The control unit of the query pipeline. It connects the user input, the OpenAI model, the conversation memory, and the Milvus retrieval tool to execute the final RAG logic.

Related n8n Workflows

Free

Nodes: 12 Nodes
Updated: December 26 2025
View all
Created by

Hi, I’m Aitor, cofounder of 1node.ai. We help businesses integrate full-scale AI solutions that save time, cut costs, and increase revenue. Guaranteed. Need help building smarter workflows? Visit 1node.ai and let's connect.

Featured*