Complete RAG System for PDF Documents using Mistral OCR, Qdrant, and Gemini AI - n8n Workflow

Create a robust Retrieval-Augmented Generation (RAG) system using an n8n workflow. Integrate Mistral OCR for PDF extraction, Qdrant vector storage, and Gemini AI for conversational Q&A.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Data scientists and developers looking for advanced n8n templates for RAG implementation.

  • Businesses needing automated PDF data extraction and knowledge base creation.

  • Users seeking to integrate complex AI services like Mistral OCR and Google Gemini into an n8n workflow.

  • Anyone requiring a scalable vector search solution using the Qdrant n8n node.

Overview

This comprehensive n8n workflow provides a complete solution for building an interactive knowledge base from unstructured PDF documents. It handles the entire lifecycle: from fetching files via the Google Drive n8n node, using the powerful Mistral OCR API for accurate text extraction (including markdown formatting for structured data), chunking the text, generating embeddings via OpenAI, and indexing them into a Qdrant vector store. The final piece is a conversational query system powered by a specialized n8n trigger and Google Gemini, allowing users to ask questions against their vectorized data, making this one of the most powerful n8n templates available for RAG.

How it Works


  1. Preparation (Qdrant Setup): The n8n workflow starts by setting up or clearing the target Qdrant collection using an HTTP Request n8n node, ensuring a clean index for new documents.

  2. Document Ingestion: The Google Drive n8n node searches for and retrieves target PDF documents from a specified folder.

  3. Sub-Workflow Execution: For each PDF, an Execute Workflow n8n node triggers a sub-process dedicated to handling OCR and vectorization.

  4. OCR and Extraction: The sub-workflow downloads the PDF and uses several HTTP Request n8n node steps to interface with the Mistral AI API. This process uploads the document, obtains a signed URL, and executes the Mistral DOC OCR, returning high-fidelity markdown structured text pages.

  5. Data Structuring: A Code n8n node structures the OCR output into individual data items for each page, preparing them for batch processing.

  6. Chunking and Embedding: The flow then leverages the LangChain components: the Token Splitter n8n node divides the content into smaller chunks (400 tokens). The Embeddings OpenAI n8n node generates vector representations for each chunk, a crucial step in any RAG implementation.

  7. Vector Indexing: The Qdrant Vector Store n8n node inserts the chunked text and their corresponding vectors into the designated Qdrant collection, completing the indexing phase of this n8n workflow.

  8. Interactive RAG Query: The second part of the system is initiated by the When chat message received n8n trigger. The user query is embedded, and the Vector Store Retriever n8n node searches the Qdrant collection for relevant context.

  9. Generation: Finally, the Question and Answer Chain n8n node combines the retrieved context with the user's question, using the powerful Google Gemini Chat Model to synthesize and return an accurate, contextually relevant answer.

Installation Guide


  1. Import: Copy the provided n8n workflow JSON and import it into your self-hosted or cloud n8n instance.

  2. Credentials Setup: This n8n workflow requires credentials for:

Mistral Cloud: For the HTTP Request n8n node steps handling OCR.
OpenAI: For the Embeddings OpenAI n8n node.
Google Gemini (PaLM): For the Chat Model n8n node.
Qdrant API (HTTP Header Auth & LangChain): Separate credentials for the low-level HTTP collection management and the specialized Qdrant Vector Store n8n node.
* Google Drive: To access your PDF source folder.

  1. Configuration: Update the placeholder values (e.g., QDRANTURL, COLLECTION) in the 'Create collection' and 'Refresh collection' HTTP Request n8n node configurations. Ensure the Google Drive n8n node ('Search PDFs') points to the correct folder ID containing your source documents.

Node Details

When clicking ‘Test workflow’ (n8n trigger): Manually initiates the entire ingestion and indexing process.
Google Drive (Search PDFs & Get PDF): Used to locate and download the source PDF documents, providing the file binary data necessary for the next step in the n8n workflow.
HTTP Request (Mistral Upload, Signed URL, DOC OCR): A set of custom n8n node requests handling the high-fidelity PDF text extraction via the Mistral OCR service.
Code: Custom n8n node scripting used to map the multi-page output from Mistral OCR into individual items, enabling the subsequent batch processing loops.
Token Splitter (LangChain n8n node): Crucial for RAG efficiency, this node chunks the extracted text to create optimally sized context windows for vector generation.
Embeddings OpenAI (LangChain n8n node): Generates the 1536-dimensional vector embeddings for text chunks, which are required for similarity search in Qdrant.
Qdrant Vector Store (LangChain n8n node): This n8n node handles both the insertion of new vectors into the ocrmistraltest collection during indexing and acts as the retrieval layer during query time.
When chat message received (n8n trigger): The interactive entry point, waiting for a chat input to begin the RAG process.
Google Gemini Chat Model (LangChain n8n node): Serves as the Large Language Model (LLM) component, utilizing gemini-1.5-flash to generate the final response based on the retrieved context.
Question and Answer Chain (LangChain n8n node): Orchestrates the final RAG logic, seamlessly integrating the Qdrant retriever output and the Gemini LLM to deliver the conversational result in this advanced n8n workflow.

Related n8n Workflows

Free

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

Full-stack Web Developer based in Italy specialising in Marketing & AI-powered automations. For business enquiries, send me an email at [email protected] or add me on Linkedin.com/in/davideboizza

Featured*