← all posts
AI
2026-07-16 10 min read

n8n RAG Pipelines: Build AI That Actually Knows Your Business

A generic LLM doesn't know your pricing, your SOPs, or your product quirks. RAG fixes that. Here's how to wire it up in n8n without a single line of Python.

Every business we work with has the same problem: they want an AI chatbot or support agent, but the moment it's asked something specific — a refund policy, a product spec, an internal process — it either hallucinates or falls back to "I don't have that information." That's a fine-tuning problem that nobody needs. What they actually need is RAG.

Retrieval-Augmented Generation (RAG) is the pattern where, instead of baking knowledge into a model, you pull the right chunks of information at query time and hand them to the LLM as context. The model reasons over real data. No hallucinations about your return policy. No outdated specs. Just accurate answers — updated whenever your source docs change.

The good news: n8n has first-class RAG support via its Vector Store nodes. You don't need LangChain, Python, or a data engineer. You need a Supabase (or Pinecone, or Qdrant) account, an embeddings model, and about 45 minutes.

the two flows you're building

A RAG pipeline has two distinct workflows. Keep them separate in your head:

Two workflows. One vector database in the middle. That's the whole architecture.

step 1: choose your vector store

n8n supports Pinecone, Qdrant, Supabase (pgvector), Weaviate, and others. For most clients, Supabase is the easiest entry point — you probably already use Postgres, and pgvector is a one-extension setup. Pinecone makes sense if you're scaling to millions of vectors and want managed infrastructure.

-- run once in your supabase sql editor create extension vector; create table documents ( id bigserial primary key, content text, metadata jsonb, embedding vector(1536) ); create index on documents using ivfflat (embedding vector_cosine_ops) with (lists = 100);

vector(1536) matches OpenAI's text-embedding-3-small. Change the dimension if you switch models.

step 2: ingestion workflow

This workflow runs on schedule or webhook trigger when docs change. Node chain:

The metadata is underrated. Tag every chunk with its document category — it's what lets you do filtered retrieval later.

⚠ chunking strategy matters

step 3: query workflow

This runs on every user message. Node chain:

The system prompt is where most RAG implementations fail. Be explicit:

// system prompt template You are a support agent for [Company]. Answer ONLY using the context below. If the answer is not in the context, say: "I don't have that information — let me connect you with a human." Do not fabricate. Do not use general knowledge about competitors or industry norms. Cite the source document when possible. Context: {{ $json.context }} Question: {{ $json.userMessage }}

filtered retrieval (the power move)

Once you've tagged chunks with metadata, you can filter retrieval by document category based on query intent. This dramatically cuts noise.

In n8n's vector store query node, pass a filter JSON. Detect the query category first (via classification step or keyword match), then filter:

// only search pricing docs for pricing questions { "category": "pricing" } // only search support docs for troubleshooting { "category": "support" }

A bot searching 50K chunks of product documentation won't accidentally pull warranty text when someone asks about upgrade pricing. The metadata filter is the difference between 70% accuracy and 95% accuracy.

keeping it fresh

real use cases

what it costs

RAG is one of the cheapest AI patterns at scale. A 5,000-page knowledge base costs under $2 to embed with text-embedding-3-small. Each query (embed + retrieve + LLM call with 2K context) runs about $0.003–0.008 with GPT-4o-mini. 1,000 queries/day ≈ $3–8/day in API fees.

where to start
pick one high-value knowledge source: FAQ doc, product catalogue, or handbook
set up supabase pgvector — 10 minutes, free tier is generous
build ingestion workflow, ingest source, verify chunk quality
build query workflow, test 10 real questions your team actually asks
add metadata filtering once you have multiple document categories
connect to slack, web chat widget, or CRM — wherever questions come in

See also: ai customer support automation end-to-end, n8n ai agent workflow patterns, and multi-agent orchestration patterns.

Want this built? we build and maintain rag pipelines for clients → from ingestion to monitoring, no python required on your end.