Build a RAG AI Agent with Milvus and Cohere in n8n

Learn how to automate document ingestion into Milvus vector store using Cohere embeddings and n8n for a powerful Retrieval-Augmented Generation (RAG) AI agent. This workflow enables quick, accurate AI responses based on your PDF data, saving you hours of manual data handling.
chatTrigger
googleDriveTrigger
vectorStoreMilvus
+9
Workflow Identifier: 1028
NODES in Use: documentDefaultDataLoader, embeddingsCohere, chatTrigger, googleDriveTrigger, googleDrive, vectorStoreMilvus, agent, vectorStoreMilvus, lmChatOpenAi, memoryBufferWindow, textSplitterRecursiveCharacterTextSplitter, extractFromFile

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

Visit through Desktop for Best experience

What this workflow does

This workflow watches a Google Drive folder for new PDF files and processes them automatically.

It extracts text from the PDFs, splits the text into small chunks, and creates embeddings of those chunks with Cohere.

Then it stores those embeddings in Milvus, a vector database, for fast search.

Finally, a chat agent uses the stored data to answer questions by finding the most relevant document pieces and generating clear responses with OpenAI GPT-4o.


Who should use this workflow

This workflow is helpful for anyone who needs to quickly find answers inside many PDF documents.

It helps teams save time by automating the boring, slow process of reading and searching PDFs.

No deep technical skills are needed to use it if basic knowledge of n8n is present.


Tools and services used

  • Google Drive: To store and monitor PDF files.
  • Extract from File node in n8n: To get text from PDFs.
  • Cohere Embeddings API: To create vector embeddings from text.
  • Milvus: To save and search vector embeddings fast.
  • OpenAI GPT-4o Chat: To generate AI answers.
  • n8n: To automate the whole pipeline.

Inputs, processing steps, and output

Inputs

  • New PDF files arriving in a specific Google Drive folder.

Processing Steps

  1. Detect new files with the Watch New Files Google Drive node.
  2. Download PDFs using Download New Google Drive node.
  3. Extract text with the Extract from File node.
  4. Structure text using the Default Data Loader node.
  5. Split texts into chunks with the Text Splitter: Recursive Character Text Splitter node.
  6. Create embeddings of chunks via the Embeddings Cohere node using model “embed-multilingual-v3.0”.
  7. Store embeddings in Milvus with the Insert into Milvus node.
  8. Wait for chat input with the When Chat Message Received node.
  9. Retrieve best documents from Milvus with Retrieve from Milvus inside the RAG Agent node.
  10. Use Memory Buffer Window to keep chat context.
  11. Generate AI answers with OpenAI GPT-4o Chat node.

Output

Fast, relevant AI answers based on the PDF documents stored in the vector database.


Beginner step-by-step: How to use this workflow in production

Step 1: Download the workflow file

  1. Find the Download button on this page.
  2. Click it to save the workflow file (.json) to your computer.

Step 2: Import workflow into n8n

  1. Open the n8n editor where your account is ready.
  2. Click on the menu, choose “Import from File.”
  3. Select the downloaded workflow file to load it.

Step 3: Configure API Keys and IDs

  1. Enter Google Drive credentials so the workflow can access your files.
  2. Put your Cohere API Key in the Embeddings Cohere node settings.
  3. Add Milvus API credentials and confirm the collection name in the Insert into Milvus node.
  4. Add your OpenAI API Key in the OpenAI GPT-4o Chat node.
  5. Update folder ID in the Watch New Files node to your Google Drive folder.

Step 4: Test the workflow

  1. Add a sample PDF to your chosen Google Drive folder.
  2. Run the workflow manually or wait for the trigger to activate.
  3. Check if the text is extracted, embedded, and stored in Milvus.
  4. Send a test chat message to see if the AI returns relevant answers.

Step 5: Activate workflow for production

  1. Turn the workflow status to active in n8n.
  2. Make sure n8n is running continuously (or see self-host n8n if needed).
  3. The workflow will watch your folder, process new PDFs, and answer questions automatically.

Customization ideas

  • Change the Cohere embedding model to match your language or data needs.
  • Adjust chunk size and overlap in the Text Splitter node to balance speed and context.
  • Replace Milvus with other vector databases like Supabase or Pinecone by switching their nodes and credentials.
  • Increase conversation memory size in the Memory Buffer Window node for longer chats.
  • Monitor different Google Drive folders by changing the folder ID in the Watch New Files node.

Common problems and solutions

  • Problem: No new files detected by the Watch New Files node.
    Cause: The folder ID might be wrong or permission issues exist.
    Solution: Check the folder ID carefully and verify Google Drive API access rights.
  • Problem: PDF extraction returns empty or error in Extract from File.
    Cause: The PDF could be encrypted or damaged.
    Solution: Try with a standard PDF or convert the PDF and test again.
  • Problem: Milvus insertion fails or times out.
    Cause: Wrong API credentials or collection info.
    Solution: Verify Milvus credential settings and check collection name, plus Zilliz cloud status if hosted.

Pre-Production checklist

  • Confirm all API credentials for Google Drive, Cohere, Milvus, and OpenAI are set correctly.
  • Test the Watch New Files node by adding a PDF and confirm it triggers.
  • Verify the Extract from File node extracts text as expected.
  • Check embeddings are created and appear in the Milvus collection.
  • Test chat questions to confirm relevant answers come back.

Deployment tips

Activate your workflow inside n8n by enabling the Watch New Files trigger node.

For cloud users, n8n runs continuously and listens for new PDFs automatically.

For self-hosted setups, keep the server running steadily; see self-host n8n for hosting ideas.

Use the n8n execution panel to monitor runs and catch errors early.

Adjust node parameters as needed based on logs and usage.


Summary of results

✓ Automates PDF ingestion and vector storage.

✓ Saves hours of manual document processing.

✓ Enables faster, accurate answers from your PDF data.

✓ Supports multiple languages via Cohere “embed-multilingual-v3.0”.

✓ Scales well with large document collections using Milvus.


Frequently Asked Questions

Check if the Google Drive folder ID is correct and confirm the Google Drive API credentials have access rights.
The PDF might be encrypted, corrupted, or unsupported. Try testing with normal PDFs or convert the PDF before extraction.
Verify the Milvus API credentials and collection name are accurate. Also check the Zilliz cloud status if using hosted Milvus.
Download the workflow file, import it from File in the n8n editor, add all API credentials, update folder and collection IDs, test with sample PDFs and chat questions, then activate the workflow.

Promoted by BULDRR AI

Related Workflows

Automate Viral UGC Video Creation Using n8n + Degaus (Beginner-Friendly Guide)

Learn how to automate viral UGC video creation using n8n, AI prompts, and Degaus. This beginner-friendly guide shows how to import, configure, and run the workflow without technical complexity.
Form Trigger
Google Sheets
Gmail
+37
Free

AI SEO Blog Writer Automation Workflows in n8n

A complete beginner guide to building an AI SEO blog writer automation using n8n.
AI Agent
Google Sheets
httpRequest
+5
Free

Automate CrowdStrike Alerts with VirusTotal, Jira & Slack

This workflow automates processing of CrowdStrike detections by enriching threat data via VirusTotal, creating Jira tickets for incident tracking, and notifying teams on Slack for quick response. Save hours daily by transforming complex threat data into actionable alerts effortlessly.
scheduleTrigger
httpRequest
jira
+5
Free

Automate Telegram Invoices to Notion with AI Summaries & Reports

Save hours on financial tracking by automating invoice extraction from Telegram photos to Notion using Google Gemini AI. This workflow extracts data, records transactions, and generates detailed spending reports with charts sent on schedule via Telegram.
lmChatGoogleGemini
telegramTrigger
notion
+9
Free

Automate Email Replies with n8n and AI-Powered Summarization

Save hours managing your inbox with this n8n workflow that uses IMAP email triggers, AI summarization, and vector search to draft concise replies requiring minimal review. Automate business email processing efficiently with AI guidance and Gmail integration.
emailReadImap
vectorStoreQdrant
emailSend
+12
Free

Automate Email Campaigns Using n8n with Gmail & Google Sheets

This n8n workflow automates personalized email outreach campaigns by integrating Gmail and Google Sheets, saving hours of manual follow-up work and reducing errors in email sequences. It ensures timely follow-ups based on previous email interactions, optimizing communication efficiency.
googleSheets
gmail
code
+5
Free