Skip to main content

Build a PDF Document RAG System with Mistral OCR, Qdrant and Gemini AI

Workflow preview

Workflow preview
100%
Build a PDF Document RAG System with Mistral OCR, Qdrant and Gemini AI preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

This workflow is designed to process PDF documents using Mistral's OCR capabilities, store the extracted text in a Qdrant vector database, and enable Retrieval Augmented Generation ( RAG ) for answ...

Best for

  • Document Extraction automation workflows
  • AI RAG automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.httprequest, n8n-nodes-base.manualtrigger, n8n-nodes-base.splitinbatches, @n8n/n8n-nodes-langchain.embeddingsopenai, @n8n/n8n-nodes-langchain.documentdefaultdataloader, @n8n/n8n-nodes-langchain.textsplittertokensplitter, @n8n/n8n-nodes-langchain.chattrigger, @n8n/n8n-nodes-langchain.chainretrievalqa

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Davide.

Original n8n.io source

1.1 Workflow description

Title
Build a PDF Document RAG System with Mistral OCR, Qdrant and Gemini AI
Workflow name
Build a PDF Document RAG System with Mistral OCR, Qdrant and Gemini AI

This workflow is designed to process PDF documents using Mistral's OCR capabilities, store the extracted text in a Qdrant vector database, and enable Retrieval-Augmented Generation (RAG) for answering questions. Here’s how it functions:

Once configured, the workflow automates document ingestion, vectorization, and intelligent querying, enabling powerful RAG applications.


Benefits

  • End-to-End Automation No manual interaction is needed: documents are read, processed, and made queryable with minimal setup.

  • Scalable and Modular The workflow uses subflows and batching, making it easy to scale and customize.

  • Multi-Model Support Combines Mistral for OCR, OpenAI for embeddings, and Gemini for intelligent answering—taking advantage of the strengths of each.

  • Real-Time Q&A With RAG integration, users can query document content through natural language and receive accurate responses grounded in the PDF data.

  • Light or Full Mode Users can choose to index full page content or only summarized text, optimizing for either performance or richness.


How It Works

  1. PDF Processing with Mistral OCR:

    • The workflow starts by uploading a PDF file to Mistral's API, which performs OCR to extract text and metadata.
    • The extracted content is split into manageable chunks (e.g., pages or sections) for further processing.
  2. Vector Storage in Qdrant:

    • The extracted text is converted into embeddings using OpenAI's embedding model.
    • These embeddings are stored in a Qdrant vector database, enabling efficient similarity searches for RAG.
  3. Question-Answering with RAG:

    • When a user submits a question via a chat interface, the workflow retrieves relevant text chunks from Qdrant using vector similarity.
    • A language model (Google Gemini) generates answers based on the retrieved context, providing accurate and context-aware responses.
  4. Optional Summarization:

    • The workflow includes an optional summarization step using Google Gemini to condense the extracted text for faster processing or lighter RAG usage.

Set Up Steps

To deploy this workflow in n8n, follow these steps:

  1. Configure Qdrant Database:

    • Replace QDRANTURL and COLLECTION in the "Create collection" and "Refresh collection" nodes with your Qdrant instance details.
    • Ensure the Qdrant collection is configured with the correct vector size (e.g., 1536 for OpenAI embeddings) and distance metric (e.g., Cosine).
  2. Set Up Credentials:

    • Add credentials for:
      • Mistral Cloud API (for OCR processing).
      • OpenAI API (for embeddings).
      • Google Gemini API (for chat and summarization).
      • Google Drive (if sourcing PDFs from Drive).
      • Qdrant API (for vector storage).
  3. PDF Source Configuration:

    • If using Google Drive, specify the folder ID in the "Search PDFs" node.
    • Alternatively, modify the workflow to accept PDFs from other sources (e.g., direct uploads or external APIs).
  4. Customize Text Processing:

    • Adjust chunk size and overlap in the "Token Splitter" node to optimize for your document type.
    • Choose between raw text or summarized content for RAG by toggling between the "Set page" and "Summarization Chain" nodes.
  5. Test the RAG:

    • Trigger the workflow manually or via a chat message to verify OCR, embedding, and Qdrant storage.
    • Use the "Question and Answer Chain" node to test query responses.
  6. Optional Sub-Workflows:

    • The workflow supports execution as a sub-workflow for batch processing (e.g., handling multiple PDFs).

Need help customizing?

Contact me for consulting and support or add me on Linkedin.

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Mistral Upload

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 2 - Mistral Signed URL

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 3 - Mistral DOC OCR

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 4 - When clicking ‘Test workflow’

Type / Role
n8n-nodes-base.manualTrigger - manualTrigger
Config choices
Version 1

Block 5 - Loop Over Items

Type / Role
n8n-nodes-base.splitInBatches - splitInBatches
Config choices
Version 3

Block 6 - Refresh collection

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 7 - Embeddings OpenAI

Type / Role
@n8n/n8n-nodes-langchain.embeddingsOpenAi - embeddingsOpenAi
Config choices
Version 1.1

Block 8 - Default Data Loader

Type / Role
@n8n/n8n-nodes-langchain.documentDefaultDataLoader - documentDefaultDataLoader
Config choices
Version 1

Block 9 - Token Splitter

Type / Role
@n8n/n8n-nodes-langchain.textSplitterTokenSplitter - textSplitterTokenSplitter
Config choices
Version 1

Block 10 - When chat message received

Type / Role
@n8n/n8n-nodes-langchain.chatTrigger - chatTrigger
Config choices
Version 1.1

Block 11 - Question and Answer Chain

Type / Role
@n8n/n8n-nodes-langchain.chainRetrievalQa - chainRetrievalQa
Config choices
Version 1.5

Block 12 - Google Gemini Chat Model

Type / Role
@n8n/n8n-nodes-langchain.lmChatGoogleGemini - lmChatGoogleGemini
Config choices
Version 1

Block 13 - Vector Store Retriever

Type / Role
@n8n/n8n-nodes-langchain.retrieverVectorStore - retrieverVectorStore
Config choices
Version 1

Block 14 - Qdrant Vector Store1

Type / Role
@n8n/n8n-nodes-langchain.vectorStoreQdrant - vectorStoreQdrant
Config choices
Version 1.1

Block 15 - Embeddings OpenAI1

Type / Role
@n8n/n8n-nodes-langchain.embeddingsOpenAi - embeddingsOpenAi
Config choices
Version 1.2

Block 16 - Code

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 17 - Wait

Type / Role
n8n-nodes-base.wait - wait
Config choices
Version 1.1

Block 18 - Qdrant Vector Store

Type / Role
@n8n/n8n-nodes-langchain.vectorStoreQdrant - vectorStoreQdrant
Config choices
Version 1.1

Block 19 - Loop Over Items1

Type / Role
n8n-nodes-base.splitInBatches - splitInBatches
Config choices
Version 3

Block 20 - Execute Workflow

Type / Role
n8n-nodes-base.executeWorkflow - executeWorkflow
Config choices
Version 1.2

Block 21 - When Executed by Another Workflow

Type / Role
n8n-nodes-base.executeWorkflowTrigger - executeWorkflowTrigger
Config choices
Version 1.1

Block 22 - Edit Fields1

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 23 - Create collection

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 24 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Showing the first 24 of 34 workflow blocks. Download the JSON for the full node graph.

3. Summary Table

Workflow Build a PDF Document RAG System with Mistral OCR, Qdrant and Gemini AI
Complexity advanced
Nodes 34
Categories Document Extraction, AI RAG
Author Davide
Published 26 May 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/4400/4400.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Build a PDF Document RAG System with Mistral OCR, Qdrant and Gemini AI do?

This workflow is designed to process PDF documents using Mistral's OCR capabilities, store the extracted text in a Qdrant vector database, and enable Retrieval Augmented Generation ( RAG ) for answ...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Document Extraction, AI RAG use case.