Templates / Local document question answering with Ollama AI, Agentic RAG & PGVector

Local document question answering with Ollama AI, Agentic RAG & PGVector

Needs changes

by Jadai kongolo ✓ · 10,599 views · created 2025-10-25 · Internal Wiki, AI RAG

Needs changes. This template uses 1 thing(s) that n8n 3.0 removes: AI Agent v1 (old agent modes). 1 breaking item(s) found. Static check, last run 2026-10-19.

What this workflow does

This AI workflow has 35 nodes and runs when a chat message arrives (plus 2 other triggers). Along the way it connects Postgres Chat Memory, Postgres, Embeddings Ollama and OpenAI Chat Model and 1 more.

How it runs

Trigger: When a chat message arrives (plus 2 other triggers).

  1. Edit Fields (Edit Fields (Set)): sets 2 fields: chatInput, sessionId
  2. Loop Over Items (Loop Over Items (Split in Batches)): loops over the items in batches
  3. RAG AI Agent (AI Agent): runs an AI agent, with model: Ollama (Change Base URL); 4 tools (List Documents, Get File Contents, Query Document Rows, Postgres PGVector Store); memory: Postgres Chat Memory
  4. Set File ID (Edit Fields (Set)): sets 3 fields: file_id, file_type, file_title
  5. Respond to Webhook: sends the response back to the webhook caller
  6. Delete Old Doc Records (Postgres): run a query
  7. Delete Old Data Records (Postgres): run a query
  8. Insert Document Metadata (Postgres): create or update
  9. Read/Write Files from Disk: reads a file from disk
  10. Switch: routes items into 4 branches

…plus 12 more steps. See the full node list below.

Services it uses

Postgres Chat MemoryPostgresEmbeddings OllamaOpenAI Chat ModelPostgres PGVector Store

Before you upgrade to n8n 3.0

1 thing in this workflow is removed in n8n 3.0. Fix it before you upgrade:

  • AI Agent v1 (old agent modes) in RAG AI Agent (v1.6): replace with Latest AI Agent node (Tools Agent). For SQL Agent, use a Postgres or MySQL tool with a recent AI Agent.

Rather not rewrite it? Many of these flows can be rebuilt in Make (free plan).

Removed in 3.0Replace with
AI Agent v1 (old agent modes)
RAG AI Agent (v1.6)
Latest AI Agent node (Tools Agent). For SQL Agent, use a Postgres or MySQL tool with a recent AI Agent.

Nodes used (20)

From the author

🚀 n8n Local AI Agentic RAG Template Author: Jadai kongolo What is this? This template provides an entirely local implementation of an Agentic RAG (Retrieval Augmented Generation) system in n8n that can be extended easily for your specific use case and…

Excerpt from Jadai kongolo's description on n8n.io.

View the original on n8n.io → Check your own copy

Get the weekly “what broke” email

New templates, newly broken ones, and n8n release changes. One short email a week.

Form not loading? Subscribe here.