Build a PDF-based RAG system with OpenAI, Pinecone and Cohere reranking
This workflow contains community nodes that are only compatible with the self-hosted version of n8n. This workflow provides a complete, ready-to-use template for a Retrieval-Augmented Generation (RAG) system. It allow...
Template notes
This workflow contains community nodes that are only compatible with the self-hosted version of n8n.
This workflow provides a complete, ready-to-use template for a Retrieval-Augmented Generation (RAG) system. It allows you to build a powerful AI chatbot that can answer questions based on the content of PDF documents you provide, using a modern and powerful stack for optimal performance.
Good to know Costs: This workflow uses paid services (OpenAI, Pinecone, Cohere). Costs will be incurred based on your usage. Please review the pricing pages for each service to understand the potential expenses. Video Tutorial (Bahasa Indonesia): For a step-by-step guide on how this workflow functions, you can watch the accompanying video tutorial here: [N8N Tutorial: Membangun Chatbot RAG dengan Pinecone, OpenAI, & Cohere](https://www.youtube.com/watch?v=pmp96hT8604&t=2s)
How it works This workflow operates in two distinct stages:
1. Data Ingestion & Indexing: It begins when a .pdf file is uploaded via the n8n Form Trigger. The Default Data Loader node processes the PDF, and the Recursive Character Text Splitter breaks down the content into smaller, manageable chunks. The Embeddings OpenAI node converts these text chunks into vector embeddings (numerical representations). Finally, the Pinecone Vector Store node takes these embeddings and stores (upserts) them into your specified Pinecone index, creating a searchable knowledge base.
2. Conversational AI Agent: A user sends a message through the Chat Trigger. The AI Agent receives the message and uses its VectorDB tool to search the Pinecone index for relevant information. The Reranker Cohere node refines these search results, ensuring only the most relevant context is selected. The user's original question and the refined context are sent to the OpenAI Chat Model (gpt-4.1), which generates a helpful, context-aware answer. The Simple Memory node maintains conversation history, allowing for natural, multi-turn dialogues.
How to use Using this workflow is a two-step process:
1. Populate the Knowledge Base: First, you need to add documents. Trigger the workflow by using the Form Trigger and uploading a PDF file. Wait for the execution to complete. You can do this for multiple documents. 2. Start Chatting: Once your data has been ingested, open the Chat Trigger's interface and start asking questions related to the content of your uploaded documents.