FlowKit

n8n template · RAG Assistant Pack

Build a RAG chatbot with citations in n8n

The heart of the RAG Assistant Pack: a public n8n chat that queries your Supabase vector store and answers with source citations. Six nodes — proof that production RAG requires neither a framework nor code.

Pipelinechatbot-rag-citations.json · 6 nodes
  1. ChattriggerChat (trigger)
  2. Assistant documentaireRAG chain (Q&A)
  3. Base vectorielle SupabaseSupabase vector store

Attached AI sub-nodes

  • Modèle OpenAIOpenAI model
  • RetrieverRetriever
  • Embeddings OpenAIOpenAI embeddings

The problem it solves

A raw LLM answers everything, including wrongly: ask it your refund policy and it will invent a plausible one. For business use, the answer must come from your documents, and be verifiable.

RAG solves both requirements: vector search supplies the relevant passages, and the prompt constrains the model to claim nothing outside that context and to cite every source. Users can verify; trust follows.

How the workflow works, node by node

Node names are in French, exactly as they appear in the imported workflow — the logic is language-agnostic.

  1. 01

    Chat

    Chat (trigger)

    Chat interface hosted by n8n, reachable by public URL — shareable with the team without building a frontend. Also manages the session ID.

  2. 02

    Assistant documentaire

    RAG chain (Q&A)

    Retrieval Q&A chain: it injects retrieved passages into the prompt ({context}) and requires answering only from them, with [source] citations and a polite refusal out of scope.

  3. 03

    Modèle OpenAI

    OpenAI model

    ai_languageModel sub-node (gpt-4o-mini). Move up to a stronger model if your documents are dense or questions span many documents.

  4. 04

    Retriever

    Retriever

    ai_retriever sub-node: brings back the 4 chunks closest to the question (adjustable topK — more context versus more noise).

  5. 05

    Base vectorielle Supabase

    Supabase vector store

    Retrieve mode on the documents table: runs the similarity search through the match_documents function, Postgres-side.

  6. 06

    Embeddings OpenAI

    OpenAI embeddings

    Vectorizes the user's question with the same model as ingestion (text-embedding-3-small) — essential: question and documents must live in the same vector space.

What you need to run it

  • n8n ≥ 1.60 with the LangChain nodes
  • A Supabase pgvector store already populated (PDF or Notion ingestion workflows from the same pack)
  • An OpenAI API key
  • The match_documents SQL function installed (provided in the pack guide)

Customization ideas

  • Adapt the prompt's tone and language (answer in English even over French documents, for instance)
  • Raise topK to 6–8 for cross-cutting questions, at a slightly higher token cost
  • Restrict access by disabling the chat's public mode and integrating it into your internal tool via the pack's API workflow

FAQ

Frequently asked questions

How do I import this template into n8n?

Import chatbot-rag-citations.json via 'Import from File', attach your OpenAI and Supabase credentials, check that the documents table contains chunks, activate, then open the public URL shown on the Chat node.

What does the bot answer when the information isn't in my documents?

The prompt requires it to say so explicitly rather than improvise: it states it can't find the information in the provided documentation and suggests rephrasing or contacting a human.

How do citations work?

Every indexed chunk carries its source metadata (file name, Notion URL…). The prompt requires each claim to be followed by its source in brackets, as it appears in the metadata of the passage used.