AI Expert Chatbot for Documentation using RAG Pipeline - n8n Workflow

Build a factual RAG AI expert chatbot using n8n to provide accurate answers exclusively from documentation. This n8n workflow leverages OpenAI embeddings and an in-memory vector store for advanced knowledge retrieval.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Automation Developers keen on learning Retrieval-Augmented Generation (RAG) techniques.
Teams needing a factual, internal AI expert based on their own documentation.
Users looking for advanced examples of n8n templates utilizing LangChain AI n8n node functionalities.
Anyone who wants a self-hosted, expert AI assistant focused exclusively on the n8n platform.

Overview

This sophisticated n8n workflow demonstrates a complete RAG implementation, structured to handle large-scale data indexing efficiently. It successfully turns thousands of pages of text into a searchable knowledge base.

Part 1: Knowledge Indexing is designed to scrape the official n8n documentation, chunk the content using the Recursive Character Text Splitter, create high-quality vector embeddings via the OpenAI Embeddings n8n node, and store them in a persistent in-memory vector store. Crucially, it utilizes an advanced n8n node configuration to prevent re-indexing content that has already been processed, making re-runs fast and resource-friendly.

Part 2: The Chatbot uses the indexed knowledge base as its sole source of truth. When a user asks a question, the system retrieves the most relevant documentation snippets and passes them to a language model (OpenAI Chat Model) instructed only to answer based on that provided context. This guarantees the chatbot is a factual expert on n8n topics, offering one of the most reliable n8n templates for deploying knowledge-based AI solutions.

How it Works

The entire n8n workflow is divided into two parts: an indexing flow (top) and a live chat flow (bottom).

Part 1: Knowledge Base Indexing


  1. The Start Indexing manual n8n trigger initiates the knowledge acquisition process.

  2. An HTTP Request n8n node fetches the main n8n documentation page, and the Extract Links from HTML n8n node pulls out all available links.

  3. Links are deduplicated and filtered to isolate only valid documentation paths.

  4. The Loop Over Documentation Pages n8n node processes these links sequentially using a sub-workflow, which is critical for stabilizing memory usage when processing numerous pages.

  5. The sub-workflow, triggered by Ingest Web Page, fetches the content of a single page, extracts the main article text, and cleans it.

  6. The Remove Duplicate Documentation Content n8n node prevents resource waste by skipping pages processed in prior executions.

  7. The cleaned documentation text is segmented using the Recursive Character Text Splitter n8n node.

  8. The chunks are converted into vectors using the Embeddings OpenAI n8n node and finally stored in the Simple Vector Store.

Part 2: Live Chatbot Querying


  1. The RAG Chatbot n8n trigger (a public chat interface) receives the user question.

  2. The n8n Docs AI Agent orchestrates the process, using the Simple Memory n8n node to maintain conversation history.

  3. The agent utilizes the Official n8n Documentation (Vector Store Retriever) as its retrieval tool. This tool converts the user query into an embedding using a separate Embeddings OpenAI n8n node and searches the vector store for the top 10 most relevant documentation chunks.

  4. The agent passes the user query, conversation history, and the retrieved documentation context to the OpenAI Chat Model (gpt-4.1-nano).

  5. The model synthesizes a highly factual response, relying only on the provided context, before sending the final answer back to the user via the RAG Chatbot n8n trigger.

Installation Guide

To deploy this powerful n8n workflow, follow these steps:


  1. Import the n8n Workflow: Copy the provided JSON and import it into your n8n instance as a new n8n workflow.

  2. Set Up Credentials: Locate any OpenAI n8n node (e.g., OpenAI Chat Model or Embeddings OpenAI). Click the Credential dropdown, select + Create New Credential, and input your OpenAI API Key.

  3. Apply Credentials: Ensure all three OpenAI n8n node instances (OpenAI Chat Model and both Embeddings OpenAI nodes) are configured to use the new OpenAI credential.

  4. Index the Documentation (Knowledge Base Building): Find the Start Indexing manual n8n trigger node at the top of the canvas. Click the "Execute workflow" button. Warning: This indexing process takes approximately 15-20 minutes to complete as it scrapes and processes the entire n8n documentation. The knowledge base is stored in memory and will be lost if the n8n instance is restarted.

  5. Activate the Chatbot: Once indexing is complete, activate the entire n8n workflow using the toggle switch. The RAG Chatbot is now live.

  6. Start Chatting: Open the RAG Chatbot n8n trigger node and use its Public URL or click the "Open Chat" button to begin interacting with your n8n documentation expert.

Node Details

RAG Chatbot (Chat Trigger n8n trigger): The user interface for the application. It uses custom CSS for a distinct look and handles incoming user messages.
Start Indexing (Manual Trigger n8n trigger): The starting point for the one-time knowledge base build operation.
Get All n8n Documentation Links (HTTP Request n8n node): Initiates the web scraping by retrieving the main documentation page HTML.
Loop Over Documentation Pages (Split In Batches n8n node): Implements a memory-safe loop, processing links in batches of 10. This ensures the large-scale indexing n8n workflow does not crash.
Remove Duplicate Documentation Content (Remove Duplicates n8n node): Configured to remember processed data from previous n8n workflow executions, guaranteeing that pages are only indexed once, even if the workflow is run multiple times.
Recursive Character Text Splitter (LangChain n8n node): Essential for RAG, this node splits raw documentation text into small, overlapping semantic chunks (1500 characters with 200 overlap).
Embeddings OpenAI (LangChain n8n node): Two instances are used: one for embedding document chunks during indexing and another for embedding the user's query during retrieval.
Simple Vector Store (LangChain n8n node): Used in two modes. During indexing, it operates in insert mode (n8ndocumentationvector_store).
Official n8n Documentation (Simple Vector Store LangChain n8n node): Used during querying, configured as a retrieve-as-tool for the AI Agent, allowing the agent to perform semantic lookups against the stored n8n knowledge base.
n8n Docs AI Agent (LangChain n8n node): The central processing unit that controls the tool usage (retrieval) and guides the language model to adhere to the strict rule of only answering based on retrieved facts.

Related n8n Workflows

Free

Nodes: 19 Nodes
Updated: December 26 2025
View all
Created by
Ayham
Ayham

Featured*