How to Build a RAG Chatbot Over Your Docs in n8n
Embed your documents into a vector store, then answer questions against them with an AI Agent so replies are grounded in your own content.
Retrieval augmented generation lets a chatbot answer from your own documents instead of guessing from training data. In n8n this is two workflows: one that ingests and embeds your files, and one that retrieves matching chunks and feeds them to an AI Agent. This guide builds both using the built-in Simple Vector Store so you can run it without external infrastructure.
What you need
- A running n8n instance with an OpenAI credential
- Some source documents (text, PDF, or markdown)
- Basic familiarity with the n8n LangChain nodes
Step 1: Build the ingestion workflow
Start a new workflow with a manual trigger. Add a node that reads your documents (Read/Write Files from Disk, or an HTTP Request for remote docs), then a Default Data Loader to convert them into document chunks, and a Recursive Character Text Splitter to keep chunks a sensible size.
Step 2: Embed and insert into the vector store
Add a Simple Vector Store node in Insert mode and give it a memory key like company-docs. Connect an Embeddings OpenAI sub-node to it. Run the workflow once to load every chunk into memory. The embeddings model turns each chunk into a vector the store can search by similarity.
Step 3: Build the chat workflow
In a second workflow add a Chat Trigger node, then an AI Agent node. Connect a Chat Model (OpenAI) sub-node to the agent for reasoning, and a Vector Store retrieval tool pointed at the same company-docs key so the agent can look things up.
You are a support assistant. Answer only using the documents
returned by the company-docs tool. If the answer is not in the
documents, say you do not know and suggest contacting support.
Always cite the section title you used.Step 4: Ask a question and check grounding
Open the chat panel and ask something only your docs would know. The agent should call the vector store tool, retrieve relevant chunks, and answer from them. If it answers without calling the tool, tighten the system message and confirm the tool is connected.
Result
You have a chatbot that answers from your own documents and admits when something is not covered. Re-run the ingestion workflow whenever the docs change, and point both workflows at a persistent vector store when you are ready to ship.
Watch related tutorials
32:08
21:45
34:10
26:40
32:15
40:20