Build a powerful RAG system using this n8n workflow. Ingest research papers, generate Voyage-Context-3 contextual embeddings, store vectors in MongoDB Atlas, and run an interactive Q&A agent powered by OpenAI. This n8n templates example showcases advanced AI flows.
Download this n8n workflow template and start using it instantly.
AI/ML Engineers developing advanced Retrieval-Augmented Generation (RAG) knowledge bases.
Researchers or analysts who need to efficiently process and query large PDF documents.
Developers seeking robust n8n templates for handling large data volumes using subworkflows.
Users interested in implementing a multi-turn chat experience using the Respond to Chat n8n node.
This comprehensive n8n workflow addresses the challenges of processing large documents (like research papers) for highly accurate Q&A. Traditional embedding methods often struggle with document context, leading to lower retrieval accuracy. This n8n workflow solves this by utilizing Voyage-Context-3, a contextual chunk embedding model that encodes context from aggregated chunks, resulting in superior vector matching.
The overall system is split into two phases: Document Ingestion and Interactive Q&A. The ingestion process, stabilized by using an n8n subworkflow for batch processing, downloads a PDF, chunks the content, generates the embeddings, and persists both the vectors and the raw text in a MongoDB Atlas vector store. The subsequent Q&A agent uses an interactive chat n8n trigger, asking clarifying questions before performing vector search and synthesizing an answer via an OpenAI RAG model.
This complex n8n workflow operates in two main logical paths: ingestion (run manually) and Q&A (run by the chat n8n trigger).
When clicking ‘Execute workflow’ n8n trigger. The Set Variables n8n node defines the URL of the research paper. Old entries are removed from the MongoDB collection by the Clear Collection n8n node.Import Research Paper n8n node (HTTP Request) downloads the PDF, and the Extract from File n8n node converts it into separate pages of text.Batch 10) and passed to the subworkflow via the Call Embeddings Subworkflow n8n node. This approach, using an n8n subworkflow, ensures stability when processing large documents.Chunk Page Text Code n8n node. These chunks are then batched (in groups of 3) and sent to the Voyage-Context-3 Embeddings API in a single bulk request, utilizing its contextual embedding capability.Insert Documents Vectors n8n node.When chat message received n8n trigger initiates the Q&A process when a user submits a query.Generate Clarifying Questions) is used to generate follow-up questions to better contextualize the user's intent. The system uses the Wait for Answer feature of the Langchain Chat n8n node in a loop to collect the user’s answers.Voyage-Context-3 Embeddings1 n8n node (configured for query input type).Perform Similarity Search MongoDB n8n node, executing a $vectorSearch aggregation query to retrieve the 10 most relevant document chunks from MongoDB Atlas.RAG Agent (OpenAI GPT-4.1-Mini), which synthesizes the final, accurate answer. The final response is delivered back to the user via the Respond to User n8n node.To use this powerful n8n workflow, follow these steps:
Authorization: Bearer YOURAPIKEY.Set Variables n8n node, define the url of the PDF document you wish to ingest. Run the workflow manually by clicking the 'Execute workflow' n8n trigger to populate your vector store.When chat message received n8n trigger.This n8n workflow relies on several specialized n8n node types for its functionality:
When chat message received (n8n trigger): The primary entry point for the Q&A system. It listens for user messages in the public chat interface.
Set Variables (n8n node): Defines the source URL for the document ingestion phase (e.g., https://arxiv.org/pdf/2402.06196).
Extract from File (n8n node): Key for RAG document processing, this node converts the imported PDF file into structured data, splitting the content by page.
Execute Workflow (n8n node): Crucial for handling large documents stably. It calls the main workflow as a subworkflow to process document pages in isolation and batches.
Code (n8n node): The Chunk Page Text code node is used for specialized text preprocessing, chunking pages into 1000-character segments with zero overlap, as recommended for contextual embeddings.
HTTP Request (Voyage-Context-3 Embeddings n8n node): Communicates with the Voyage.ai API to generate contextual embeddings. It is configured to send grouped inputs using the document input type during ingestion and the query input type during retrieval.
MongoDB (n8n node): Used extensively for both storage and retrieval. The Insert Documents Vectors n8n node persists the text chunks and their corresponding embeddings. The Perform Similarity Search n8n node executes the native MongoDB $vectorSearch aggregation query.
Information Extractor (Langchain n8n node): The Generate Clarifying Questions n8n node utilizes a structured output LLM call to generate a list of questions to improve the search context.
Use this advanced n8n workflow to build a powerful Retrieval-Augmented Generation (RAG) system. Integrate Google Drive, OpenAI embeddings, and Pinecone DB for instant document Q&A via chat or a custom UI webhook.

Build a powerful RAG system using this n8n workflow. Automatically index Google Drive files into a vector store and answer questions via Telegram using the GPT-4-mini n8n node.

Deploy a custom AI Document Q&A chatbot on Telegram using this powerful n8n workflow. Integrates Google Gemini, Supabase vector storage, and advanced RAG capabilities. Explore n8n templates for AI.

Use this comprehensive n8n workflow to ingest PDF documents, generate embeddings with OpenAI, store data in Weaviate, and perform instant Q&A using RAG. Ideal n8n templates for document analysis.

Freelance AI Automation Engineer based in London, UK. Since 2024, my n8n templates have documented my journey into applied AI and have helped hundreds of businesses and organisations get up to speed with AI automation. Today, I continue to explore use-cases as AI evolves and occasionally upload templates which I find novel and interesting. Subscribe to the RSS Feed: https://cdn.subworkflow.ai/n8n-templates/rss.xml







































