Phase 2: n8n for AI Automation · 55 min · n8n · Pinecone · Qdrant
Vector Stores and RAG in n8n
Retrieve before you generate.
Hiring signal: RAG in n8n is the bridge between simple automations and production AI systems. Being able to configure vector store nodes, embedding models, and retrieval workflows in n8n demonstrates the full-stack automation skill that enterprise roles require.
What you will learn
- Connect n8n to vector stores: Pinecone, Qdrant, Supabase pgvector, Chroma, Weaviate
- Configure embedding models: OpenAI text-embedding-3, Cohere embed, local models via Ollama
- Build the RAG pattern in n8n: retrieve context → pass to AI Agent → generate grounded response
- Create document ingestion workflows: PDF → chunk → embed → store in vector DB
The Problem
A law firm uses n8n to automate email classification. Each email is parsed, categorized, and routed. But when a partner asks, "What did we tell the client about the non-compete clause in last quarter's negotiation?", the system has no answer. The emails exist in the CRM, but there's no way to search them by meaning — only by keyword. A search for "non-compete" misses the email where the lawyer wrote "restrictive covenant" instead.
This is the RAG problem: you have documents, you have an LLM, but the LLM doesn't know your documents. You need to retrieve the right chunks from your document store and pass them to the LLM as context before it generates an answer. n8n makes this possible with vector store nodes, embedding models, and the AI Agent node — all wired together visually.
RAG is not a search engine with an LLM bolted on
The retrieval step and the generation step are coupled. The quality of your embeddings, your chunking strategy, and your vector store configuration directly determines what the LLM can and cannot answer. A great LLM with poor retrieval produces confident hallucinations. A mediocre LLM with excellent retrieval produces grounded, useful answers.
The Concept
The RAG Pattern in n8n
┌─────────────────────────────────────────────────────────────────────┐
│ INGESTION WORKFLOW (runs once per document) │
│ │
│ Trigger → Extract Text → Chunk → Embed → Store in Vector DB │
│ (upload) (PDF node) (split) (OpenAI) (Pinecone/Qdrant) │
└─────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────┐
│ QUERY WORKFLOW (runs per user question) │
│ │
│ Trigger → Embed Question → Vector Search → AI Agent → Response │
│ (webhook) (OpenAI) (top-k) (context+LLM) (grounded) │
└─────────────────────────────────────────────────────────────────────┘
Vector Store Nodes in n8n
n8n provides built-in vector store integration nodes that support the most popular vector databases:
| Vector Store | n8n Node | Best For | Self-Host? |
|---|
| Pinecone | Pinecone Vector Store | Managed, production scale, serverless | No (SaaS) |
| Qdrant | Qdrant Vector Store | Self-hosted or managed, fast filtering | Yes |
| Supabase pgvector | Postgres (pgvector) | Already using Supabase, SQL queries on vectors | Yes (or SaaS) |
| Chroma | Chroma Vector Store | Local dev, prototyping, lightweight | Yes |
| Weaviate | Weaviate Vector Store | Hybrid search, GraphQL, modules | Yes (or SaaS) |
Each vector store node in n8n supports the same core operations:
- Insert: Add documents with embeddings and metadata
- Retrieve: Search for similar documents given a query embedding
- Update: Modify existing documents
- Delete: Remove documents by ID or filter
Embedding Models
Embeddings are the bridge between text and vectors. n8n supports multiple embedding providers:
| Provider | Model | Dimensions | Cost (per 1M tokens) | Notes |
|---|
| OpenAI | text-embedding-3-small | 1536 | $0.02 | Default, good quality |
| OpenAI | text-embedding-3-large | 3072 | $0.13 | Higher quality, more storage |
| Cohere | embed-english-v3 | 1024 | $0.10 | English-optimized |
| Ollama | nomic-embed-text | 768 | Free (local) | Self-hosted, no API cost |
Match embedding dimension to your vector store index
When you create a Pinecone index or Qdrant collection, you must specify the dimension. If you create an index for 1536 dimensions (text-embedding-3-small) and later switch to a 768-dimension model (nomic-embed-text), you'll need to recreate the index. Plan your embedding model before creating your vector store.
The Retrieval Step
The key parameters that control retrieval quality:
| Parameter | What It Does | Typical Value |
|---|
topK | Number of chunks to retrieve | 3–10 |
scoreThreshold | Minimum similarity score (0–1) | 0.7–0.85 |
filter | Metadata filter (e.g., source, date) | Varies |
Your RAG system returns irrelevant chunks when users ask questions about recent documents. What parameter would you adjust first?
If the problem is recency (not relevance), adding a metadata filter like {"date": {"$gte": "2025-01-01"}} restricts retrieval to recent documents. Increasing topK would return more irrelevant chunks. A larger embedding model won't fix a date filtering problem. Increasing the score threshold might return zero results if no recent chunks meet the threshold.
Document Ingestion: Chunking Strategy
The chunking strategy determines how documents are split before embedding. Bad chunking = bad retrieval.
| Strategy | Chunk Size | Overlap | Best For |
|---|
| Fixed-size | 500–1000 tokens | 50–100 tokens | General purpose, simple |
| Sentence-aware | 3–5 sentences | 1 sentence | Legal, technical docs |
| Paragraph-aware | 1–3 paragraphs | 0–1 paragraph | Articles, reports |
| Recursive | 1500 → 500 → 100 | 100 tokens | Mixed content, fallback |
Unlock the full lesson
You've read the first 2 sections. The rest of this lesson covers Build It, Use It, Ship It, Exercises, Key Terms, Common Pitfalls — plus a hands-on lab, quiz, and project artifact.
Create a free account to unlock Phase 0 and Phase 1 of every course — no credit card.
Browse all courses · View pricing · DeVenture Academy