Skip to content
Loïc Chossière AI Consultant

Free guide

How to create a RAG with N8N to set up AI customer support with your business documents

You dream of a chatbot capable of precisely answering questions about your terms and conditions, your internal documentation, your procedures or even your API? RAG, or Retrieval-Augmented Generation, is the right solution for you.

  • 19 min read
  • 14 chapters
  • No email address required

Why RAG changes everything

You dream of a chatbot capable of precisely answering questions about your terms and conditions, your internal documentation, your procedures or even your API? RAG, or Retrieval-Augmented Generation, is the right solution for you.

Unlike conventional chatbots that "hallucinate" approximate responses, an AI agent based on RAG:

  • retrieves the exact information in your documents
  • generates a clear, appropriate response in natural language
  • is based on your up-to-date, private business data

In this comprehensive tutorial, you will learn how to create a personalized AI assistant (RAG) for customer support (or any other area), without coding, thanks to N8N an open-source visual automation platform.

By the end of this guide, you'll know how to:

  • Prepare and index your documents (PDF, FAQ, internal docs...)
  • Transform them into a vector-based knowledge base
  • Create an AI chatbot that really understands them
  • Offer an interface (chat, form, API...)
  • And even monetize this technology for your customers or your own SaaS.

Understanding the basics of RAG

RAG, or Retrieval-Augmented Generation, is a method that enables artificial intelligence to generate reliable answers based on your own documents.

The problem with classic AIs

A chatbot based solely on a model like GPT can give convincing answers... but often wrong ones. Why? Because it only knows what it's trained on (up to a certain date) and doesn't have access to your internal content.

The solution: RAG

RAG adds a key step: content retrieval. Before responding, the AI searches for the most relevant documents in a database created from your files (PDF, DOC, Notion, etc.). It reads them, then writes a response based on this specific information.

In short, a RAG agent combines:

  1. Retrieval: intelligent data search
  2. Generation Writing a clear response using a language model (LLM)

Thanks to this, you get an AI assistant that can:

  • Answer questions about your terms and conditions, product sheets or internal documents
  • Create a dynamic, up-to-date knowledge base
  • Manage automatic 24/7 customer support based on your rules

The RAG doesn't replace conventional AI, but reinforces it by giving it access to your knowledge.

Preparing data for RAG

Before you can build an intelligent chatbot, you need to provide it with reliable, well-structured sources. This stage is often neglected, even though it determines the relevance of the answers generated by AI.

What types of documents are compatible with a RAG?

RAG works equally well with structured and unstructured content:

  • ✅ PDF files (terms and conditions, contracts, manuals, reports...)
  • ✅ HTML pages or internal sites (exported or scraped)
  • ✅ Text or Markdown files
  • ✅ Data from Google Docs, Notion, Airtable...
  • ✅ Emails, FAQs, internal articles

Good structuring practices

  • Using clear titles (H1, H2) to guide segmentation
  • Add dates, authors, categories if possible
  • Avoid long paragraphs of more than 1000 characters
  • Prefer thematic documents rather than overly general ones

💡 Tip: if your documents are poorly organized, start by converting them into a simple format (Markdown or Google Doc), which you can then cut up more easily.

File organization

To simplify management, create a clear tree structure:

  • /docs/ → all processed documents
  • /docs/support/ → General terms and conditions, after-sales procedures
  • /docs/api/ → OpenAPI files, dev guides
  • /docs/faq/ → public documentation

🧩 This organization will then enable you to manage specialized RAGs by theme, customer or language.

Practical tools for cleaning/structuring your data

  • ChatGPT (or Claude) to summarize, correct and standardize a text
  • Docsplit, Gotenberg to convert PDFs to text
  • Google Docs API to automate content extraction
  • Regex or AI to identify blocks of meaning in raw documents

✅ Well-prepared data = more reliable, accurate and rapid answers.

Ingestion: create the vector base

Once your documents are ready, you need to transform them into a database that can be consulted by your AI. This database is not a conventional database: it's called a vector because it contains mathematical representations (called embeddings) of the texts.

Why use a vector base?

Language models can't "read" like humans. They need to compare vectors, i.e. series of numbers representing the meaning of a text. Thanks to this, we can quickly find the passages closest to a user's question.

Ingestion stages in N8N

  1. Load documents Google Drive, webhook, local upload, Dropbox, Notion, etc.
  2. Extract text content PDF, HTML, Markdown, plain text nodes
  3. Split the text into chunks: via the Text Splitter node
  4. Generate embeddings for each chunk: node Generate Embedding
  5. Store vectors in a vector store: node Vector Store

Example with OpenAI + Pinecone

  • 📥 PDF → Node Read PDF
  • ✂️ Cutting: RecursiveCharacterSplitter
  • 🔢 Embedding: model text-embedding-3-small from OpenAI
  • 💾 Storage: Pinecone (or Supabase PGVector for free option)

Each chunk is stored with useful metadata: document name, source, language, date, etc.

Configuration tips

  • Use an overlap of 20-30% so as not to lose context between two chunks
  • Choose chunks of 300 to 600 tokens for the right balance between relevance and cost.
  • Keep a document ID for later filtering by category

Vector stores compatible with N8N

  • 🔷 Pinecone - ultra-fast, simple API, ideal for production
  • 🟢 Supabase PGVector - free and self-hostable
  • 🟠 Qdrant - open source, fast, widely used in RAG projects
  • 🟪 Weaviate - complete with hybrid search engine

✅ With this foundation in place, you've created your AI's memory.

Answer retrieval & generation

Once your documents have been transformed into vectors and stored in a database, you can query this database on the fly, based on a user query. RAG combines two key operations:

  • 🔍 Retrieval find the most relevant chunks by similarity
  • 🧠 Generation create a clear, natural-language response from these elements

N8N workflow steps for answering a question

  1. Receive user question (chat, webhook, email...)
  2. Turning the question into a vector (node Generate Embedding)
  3. Querying the vector base (node Query Vector Store)
  4. Reinject found chunks in a prompt
  5. Calling up an LLM model (node LLM Agent or Chat Completion)
  6. Send reply (by email, web interface, API...)

A concrete example

Question: "What to do if you withdraw from an online purchase?"
➜ AI queries your PDF of terms and conditions
➜ It extracts the "Right of withdrawal" section.
➜ It reformulates a clear answer, with deadline, procedure, and link to the form

Key nodes in N8N

  • Chat Trigger or Webhook the question's entry point
  • Generate Embedding transforms the question into a vector
  • Query Vector Store: retrieves the nearest chunks
  • LLM Agent or Chat Completion: create answer
  • Send Email or Telegram customized output

Tips for efficient generation

  • 🎯 Limit request to 3 to 5 chunks to avoid overloading
  • 📋 Inject a strict prompt: "Answer only from these documents..."
  • 🔗 Cite your sources if possible (file name, line of text, internal link...)

✅ You've just created an AI assistant that really understands what you're asking... because it'll read your documents before answering.

Creating a chatbot interface

Once your RAG agent is up and running in N8N, you can open it up to your users via a chat interface. The aim is to make the experience simple, interactive and personalized, without the need to develop a complete application.

Option 1 - Use N8N's native chat interface

  • ✅ Accessible from node Chat Trigger
  • ✅ Simulate conversations directly in the editor
  • ❌ Limited to test use, without visual customization

Option 2 - Create a customized web interface

Here are several solutions for integrating your AI agent into a website or app:

  • 🧱 Framer / Webflow Integrate a form or widget that calls an N8N Webhook
  • 🔗 Classic HTML form sends question to Webhook, retrieves answer via API
  • 💬 JS chat widget (like Tidio or Chatbase, connected to N8N in the backend)
  • ⚙️ Bubble.io or Glide: front no-code + backend N8N

Option 3 - Connect to messaging services

  • 💬 Telegram very easy to connect via dedicated nodes
  • 📘 Messenger via Meta API + Webhook
  • 📱 WhatsApp Business: requires a provider like Twilio
  • 🟣 Discord simple API for community bots or in-house support

UX recommendations

  • Add an "answer in progress..." animation while waiting for the LLM
  • Keep history locally or server-side for long conversations
  • Display a privacy message if user data is sensitive

✅ A good interface transforms a simple AI agent into a real product that is usable, fluid and reassuring for the end user.

Detailed case studies

Here are several concrete examples of RAG agents built with N8N, each adapted to a specific business domain. These cases can be easily adapted to your own business, customers or internal projects.

Case 1 - Document-based customer support

  • Data: GTC, return policy, FAQ, PDF tutorials
  • Objective: answer customers' common questions 24/7
  • Special feature: document filtering by type or category (after-sales service, delivery, refund, etc.)
  • Example question: "How long do I have to return a product?"

Case 2 - Developer assistant for internal API

  • Data: OpenAPI specifications, authentication guides, code snippets
  • Objective: help devs integrate APIs quickly
  • Special feature: the agent can generate code, headers or detect frequent errors.
  • Example: "How do I create a POST request with OAuth2 in Node.js?"

Case 3 - Intelligent financial agent

  • Data: annual reports, quarterly results, stock market indices
  • Objective: summarize trends or compare periods
  • Special feature: integration with external real-time data (via HTTP Request)
  • Example: "How have Tesla's sales evolved between 2022 and 2024?"
  • Data: collective agreements, model contracts, internal procedures
  • Objective: answer HR or legal questions without human intervention
  • Special feature: tone management, verification of legal source
  • Example: "What is the notice period for a permanent contract after 3 years' service?"

Case 5 - Product-specialized e-commerce agent

  • Data: technical data sheets, manuals, operating instructions
  • Objective: advise visitors or manage technical after-sales services
  • Special feature: can filter by product reference or category
  • Example: "How do I change the cartridge in model D340?"

💡 These workflows can be imported, cloned and adapted to your needs via exportable JSON templates from N8N.

Automate ingestion & updating

A static RAG quickly becomes obsolete. To keep an AI agent up to date and efficient, it is essential to automate ingestion and revectorization of documents as soon as a file is modified or added.

Objective: continuous ingestion

Each time a new document is added to Google Drive, Notion or Dropbox:

  • It is automatically detected
  • Converted and cut if necessary
  • Its chunks are transformed into embeddings
  • They are added to or updated in your vector database

Example: Google Drive → Pinecone (automatic workflow)

  1. Google Drive Trigger monitors the addition of new files to a specific folder
  2. Read PDF reads and extracts the text content of the file
  3. Text Splitter cuts text into chunks
  4. Generate Embedding generates vectors
  5. Vector Store stores embeddings in Pinecone or Supabase

Automatic update

  • Each document is identified by a slug or a unique document_id
  • In the event of a modification, the old content is deleted and replaced in the vector database.
  • Use metadata (date, version, language...) to manage conflicts

Deleting obsolete documents

  • Schedule a cleanup with a Cron node or a Python script
  • Check documents marked as "deprecated" or "archived".
  • Remove their vectors from the database (via ID or metadata)

Best practices

  • 🚦 Add a queue (node Wait) to avoid conflicts if several files arrive at the same time
  • 🧪 Log updates (date, title, status) in a Google Sheet or Airtable
  • 🔐 Check formats before ingestion (PDF, UTF-8, no empty files)

✅ Thanks to this automation, your AI agent will always stay as close as possible to your latest business data.

Advanced case: autonomous multi-customer support

Do you offer an outsourced support service for several customers? Or are you developing a white-label SaaS solution? It's possible to create a RAG agent capable of responding according to the customer concerned, without mixing knowledge bases.

Typical use case

  • 📂 Each customer has his or her own documents (terms and conditions, notices, internal policies, etc.).
  • 🧠 Each vector base is separated or filtered
  • 🤖 The agent responds contextually according to the origin of the request

Possible methods

1. 🔐 A single vector base with dynamic filtering

  • Store all vectors in the same database, with metadata client_id
  • When querying, filter only chunks from the right customer
  • ➡️ Easy to maintain, but be careful to partition the space

2. 🧱 One vector base per customer

  • Create one Pinecone/Supabase instance per customer
  • Workflow dynamically queries the right database for the customer
  • ➡️ More secure, but more complex to manage on a large scale

Dynamically identify the customer

  • Via the sub-domain (e.g. client1.monsaas.com)
  • Via email address or session token
  • Via the original document if uploaded from a specific interface

Multi-client document management

  • Create a Google Drive or folder for each customer
  • Add a "client_id" column to your Google Sheets / Notion
  • Automatically generate an import log for each customer

Example of hybrid architecture

  • All files in Google Drive
  • Google Sheet with file → customer correspondences
  • N8N reads this mapping to direct ingestion to the right base
  • The AI agent dynamically loads the correct vector base for each question

✅ With this system, you can manage an unlimited number of customers, each with its own AI agent... without ever mixing their data.

Tests, performance & limits

A functional RAG agent is not enough: it must also be tested, optimized and its limits understood, to guarantee reliable, rapid and relevant responses.

How to test a RAG agent effectively?

  • ✅ Ask specific questions on each type of indexed document
  • ✅ Test formulation variants (e.g. "return policy" vs. "refund")
  • ✅ Check that the AI knows how to say "I don't know" if the answer is not in the database.
  • ✅ Add tricky cases (conflicting documents, old files)

Performance and speed

  • The larger the corpus, the longer the search ➜ limit to top_k = 4 results
  • LLM inference can be slow ➜ prefer fast models (flash/instant)
  • Pre-filtering by category or customer greatly speeds up searches

Chunk optimization

  • Ideal size: between 300 and 600 tokens
  • Recommended overlap: 50 to 100 tokens to maintain context between two pieces
  • Clean up documents that are too short, irrelevant or empty before ingestion

Known RAG limits

  • Hallucinations if the prompt does not require adherence to documents
  • Vague answers if the retrieved chunks are too far away from the question
  • Obsolete documents: without automatic update, the answer may be wrong
  • No complex multi-document reasoning (LLM contextual limit)

Security & verification

  • Add a log of answers given (question + source used)
  • Filter access to sensitive vector databases (authentication required)
  • Test each version before putting it into production, especially for customer or legal support.

✅ A well-tested and optimized RAG agent will be 10x more useful and credible in the eyes of your users... and will save you a lot of mistakes.

Extend your AI RAG agent

Once your RAG is up and running, you can make it even more powerful by adding advanced functions. These optional modules increase the added value of your AI agent, making it a truly comprehensive professional tool.

Add complementary semantic search tools

  • Add a keyword search before RAG
  • Display results found before generation (style "Here's what I found:...")
  • Use a hybrid engine (Qdrant, Weaviate) combining keywords + vectors

Enriching the agent's reasoning

  • Add a "memory tool"to contextualize previous exchanges
  • Create a self-reflection loop ("the agent reformulates his answer if in doubt")
  • Integrate calculations or verifications (e.g. amount incl. VAT, legal deadlines, etc.)

Multilingual & international

  • Automatically detect the input language and translate the prompt
  • Use multilingual LLMs (OpenAI, Mistral, Claude, Gemini Pro)
  • Index documents in multiple languages, with language metadata

Adding voice channels

  • Integrate Whisper (voice-to-text transcription)
  • Add ElevenLabs, Play.ht or Google TTS for voice response
  • Connect to Twilio or WhatsApp for interactive audio assistance

Add access rules

  • Filter data by user profile (customer, employee, admin...)
  • Integrate a JWT or OAuth tokenization module to restrict access
  • Log sensitive requests, with alerts for confidential content

✅ By adding these optional building blocks, you go from a simple AI chatbot to a genuine intelligent, secure and scalable business application.

Monetize a RAG agent

A RAG-based AI agent is not just an internal tool. It is also a saleable service offering a SaaS product, or a premium solution for your customers. Here are several possible business models for making money selling a RAG agent created with N8N.

1. Outsourced support service

  • Target: SMEs, lawyers, e-tailers, agencies...
  • You create a custom agent from their documentation
  • Delivery via web chatbot or embeddable API
  • Pricing: monthly subscription + initial setup

2. Functionality in an existing SaaS

  • Integrating an AI assistant into your own product
  • Example: HR platform ➜ agent who reads the labour code + internal policy
  • Pro" or "Premium" rate for agent access

3. RAG as a Service" product

  • Centralized platform where each customer can upload documents
  • Automated ingestion (see Part 7)
  • Automatically generated agent, accessible via an interface or API
  • Pricing by volume, usage or number of documents

4. Agency or freelance offer

  • You propose the implementation of a documented AI chatbot to your customers
  • Integration into their website, Notion, intranet, CRM or customer area
  • Standard quote: technical setup + monthly maintenance option

5. Paid access to an expanded document base

  • You create a database (legal FAQ, job descriptions, training courses, etc.) enhanced by an AI agent.
  • Access is by subscription or paid account
  • The agent becomes an exclusive intelligent search service

✅ A well-constructed RAG agent can be monetized as a product, a service or an integrable technology building block.

Guided exercise: creating a RAG chatbot step by step with N8N

From theory to practice! This step-by-step exercise guides you through the creation of an AI RAG agent capable of answering questions on GitHub's API documentation. Objective: build a chatbot based on your own documents, connecting N8N to a vector base and an LLM.

Before you start

  • ✅ An N8N account (cloud or self-hosted via Docker, Coolify, etc.)
  • ✅ OpenAI API key (for embeddings + generation)
  • ✅ A Pinecone account (or Supabase PGVector) to store vectors
  • ✅ A basic understanding of vector databases (not mandatory, but useful)

Step 1 - Preparing the data to be indexed

  • Add a node HTTP Request to retrieve the OpenAPI 3.0 file from a raw GitHub URL (JSON format)

  • This file contains all the technical documentation for the GitHub API.
  • It will then be used to feed our vector database

Step 2 - Generating and storing embeddings in Pinecone

In this key step, we'll create vector representations (embeddings) from the documentation content, then automatically store them in a Pinecone vector database.

  • Start by adding a node Pinecone Vector Store and set it to "Save Document Chunks

  • Then add a node OpenAI Embeddings and connect it to the Vector Store

  • Use the text-embedding-3-small model and your OpenAI credentials
  • Add a node Default Data Loader to manage document flow

  • Finally, connect a Recursive Character Text Splitter node to the Data Loader to split content into suitable fragments

📌 All these nodes are connected in cascade: the Text Splitter cuts, the Data Loader loads, the Embeddings node transforms each chunk into a vector, and the Pinecone Vector Store stores them.

Step 3 - Save vectors

Run this ingestion workflow: the chunks will be vectorized and stored in Pinecone. You can view their presence via the Pinecone dashboard.

💡 This part is an independent workflow that can be reused regularly.

Step 4 - Building the conversational chatbot

  1. Add a node Chat Trigger to receive questions
  2. Add an AI Agent in Tools Agent mode
  3. Add a system prompt: "You're an assistant specializing in the GitHub OpenAPI v3 API."

  1. Add an OpenAI Chat Model (gpt-4o-mini recommended)

Step 5 - Connecting to the vector base

  • Add a node Window Buffer Memory to keep things in context

  • Add a Vector Store Tool with explicit description (e.g. "OpenAPI GitHub")

  • Connect it to a Pinecone Vector Store ("Retrieve Documents" mode)

  • Add a node OpenAI Embeddings to transform the question

  • Add a second Chat Model to summarize the answer

Step 6 - Testing your AI RAG agent

Use N8N's "Chat" interface to ask a question (e.g. "How do I create a github app from a manifest?"). You'll see the agent fetch the right passages from Pinecone and generate a complete answer.

🎉 Result obtained

  • ✅ 1 ingestion workflow (OpenAPI → Pinecone)
  • ✅ 1 conversational workflow (user chat → enriched response)
  • ✅ A functional intelligent agent, ready to be adapted to your own data

🎯 Conclusion - What you can do next

You've just read a complete guide to creating an AI RAG agent with N8N. You've learned how to structure your documents, create a vector database, build an intelligent chatbot, and even monetize your solution.

This type of agent is much more than an assistant: it's a genuine technology building block which you can integrate into SaaS projects, customer services, internal tools, or resell to your business customers.

Next steps

  • 📚 Explore new use cases (HR, legal, commercial, medical...)
  • 🧰 Add advanced functions (long memory, voice, data actions)
  • 🌍 Deploy your agent in your site, CRM or customer interface
  • 💸 Create your own RAG-as-a-Service (multi-client) platform

N8N + RAG = autonomy, scalability, power. Now it's your turn.