Document Q&A with Weaviate Retrieval-Augmented Generation (RAG) - n8n Workflow

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.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Technical users and developers specializing in Retrieval-Augmented Generation (RAG).

  • Knowledge managers requiring searchable infrastructure for large documents.

  • Automation specialists seeking advanced AI n8n workflow examples.

  • Anyone looking for robust n8n templates to implement custom knowledge bases.

Overview

This powerful n8n workflow provides a complete solution for building a knowledge base from unstructured PDF data using the RAG architecture. It solves the common problem of querying large, domain-specific documents by first extracting the text, chunking it, creating vector embeddings via OpenAI, and securely storing these vectors in a Weaviate cluster. By dividing the process into data ingestion and query serving, this n8n automation ensures high efficiency and accurate, grounded responses. The entire system is built using specialized n8n node components designed for LangChain integration, making it one of the most technical and valuable n8n templates available for production-grade AI applications.

How it Works

This n8n workflow operates in two distinct phases: Data Ingestion and Query Execution.

Phase 1: Data Ingestion


  1. Upload PDF Trigger: The process starts with the Upload PDF n8n trigger (a Form Trigger), which accepts the PDF file from the user.

  2. Extraction: The Extract from File n8n node parses the uploaded binary file, extracting the full text content.

  3. Preparation: The Edit Fields n8n node formats the extracted text into a usable text field.

  4. Chunking and Loading: The data is processed by the Recursive Character Text Splitter1 (chunk size 500) and the Default Data Loader n8n node.

  5. Embedding: The Embeddings OpenAI n8n node generates vector representations for each text chunk.

  6. Vector Storage: Finally, the Weaviate Vector Store n8n node inserts the embedded documents into the designated Weaviate collection ('FileUpload').

Phase 2: Query Execution (RAG)


  1. Chat Trigger: The query phase begins when a message is received by the When chat message received n8n trigger.

  2. RAG Orchestration: The user's query is passed to the Question and Answer Chain n8n node.

  3. Language Model: This chain utilizes the OpenAI Chat Model (configured for gpt-4-mini) to structure the final answer.

  4. Retrieval: The chain queries the Vector Store Retriever, which uses the Weaviate Vector Store1 n8n node and the Embeddings OpenAI1 n8n node to perform a semantic search against the Weaviate database. It retrieves the most relevant text chunks from the original PDF.

  5. Answer Generation: The Question and Answer Chain sends the original query, along with the retrieved context (chunks), to the OpenAI model, ensuring the final answer is accurately grounded in the PDF content.

Installation Guide

To deploy this RAG n8n workflow, follow these steps:


  1. Import: Copy the provided JSON code and import it into your n8n instance via the 'Workflows' menu.

  2. Weaviate Setup: Ensure you have an operational Weaviate cluster (local or Weaviate Cloud). Configure the Weaviate Credentials connection used by the Weaviate Vector Store n8n node.

  3. OpenAI Credentials: Set up your OpenAI API key credentials and apply them to the Embeddings OpenAI and OpenAI Chat Model n8n node instances.

  4. Database Collection: Verify the Weaviate collection name used across the workflow is consistent (default is 'FileUpload').

  5. Initial Run (Ingestion): Execute the workflow manually via the Upload PDF n8n trigger (Form Trigger URL) to upload your target PDF file and ingest the data into Weaviate.

  6. Testing (Query): Once ingestion is complete, use the URL provided by the When chat message received n8n trigger to send chat queries and test the RAG functionality of the n8n template.

Node Details


  • Upload PDF (Form Trigger): The starting n8n trigger for data ingestion. It prompts the user to upload a file named 'PDF File'.

  • Extract from File (n8n node): Crucial for preparing data. It specifically runs the 'pdf' operation to extract raw text content from the binary input.

  • Recursive Character Text Splitter1: A LangChain n8n node used to break down the large document into smaller chunks (Chunk Size: 500 characters) suitable for embedding and retrieval.

  • Embeddings OpenAI / Embeddings OpenAI1: LangChain n8n nodes responsible for turning text chunks (ingestion phase) or the search query (query phase) into high-dimensional vector embeddings using the configured OpenAI API credentials.

  • Weaviate Vector Store (n8n node): Manages the persistent storage and indexing of the vectorized PDF data into the Weaviate database, using the 'FileUpload' collection.

  • When chat message received (Chat Trigger): The primary n8n trigger for the query side of the system, receiving user text input (chatInput).

  • OpenAI Chat Model: Configured as the LLM (gpt-4-mini) for the RAG process, handling the synthesis of the final answer based on the retrieved context.

  • Question and Answer Chain: The coordinating LangChain n8n node. It accepts the user query and uses the connected Retriever and Language Model to produce the grounded response. The instruction dictates using only the attached Weaviate collection for answers.

Related n8n Workflows

Free

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

Machine Learning Engineer at Weaviate.

Featured*