Templates / Build an OpenAI RAG system with document upload, semantic search and caching

Build an OpenAI RAG system with document upload, semantic search and caching

Ready for 3.0

by ResilNext ✓ · 764 views · created 2026-04-06 · Internal Wiki, AI RAG

Ready for 3.0. This template uses no nodes that n8n 3.0 removes. No removed nodes, versions or helpers found. Static check, last run 2026-10-19.

What this workflow does

This AI workflow has 20 nodes and runs when an HTTP POST request hits its webhook URL. Along the way it connects Embeddings OpenAI, Postgres PGVector Store, Postgres and OpenAI Chat Model and 1 more.

How it runs

Trigger: When an HTTP POST request hits its webhook URL.

  1. Workflow Configuration (Edit Fields (Set)): sets 5 fields: chunkSize, chunkOverlap, topK…
  2. Route by Action (Switch): routes items into 2 branches
  3. Extract Text from Document (Extract from File): extracts data from a file (pdf)
  4. Check Query Cache (Postgres): run a query
  5. Store Embeddings in PGVector (Postgres PGVector Store): stores documents in the Postgres PGVector Store vector store, with embeddings: OpenAI Embeddings; document loader: Document Loader
  6. Cache Hit or Miss (Switch): routes items into 2 branches
  7. Log Upload to Cache (Postgres): run a query
  8. Format Cached Response (Edit Fields (Set)): sets 3 fields: answer, cached, user_id
  9. Answer Query with Context (AI Agent): runs an AI agent, with model: OpenAI Chat Model; 1 tool (Answer questions with a vector store)
  10. Respond Upload Success (Respond to Webhook): sends the response back to the webhook caller

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

Services it uses

Embeddings OpenAIPostgres PGVector StorePostgresOpenAI Chat ModelVector Store Question Answer

Before you upgrade to n8n 3.0

Nothing in this workflow is removed in n8n 3.0, so it should import and run after the upgrade.

Nodes used (13)

From the author

Overview This workflow implements a complete Retrieval-Augmented Generation (RAG) system for document ingestion and intelligent querying. It allows users to upload documents, convert them into vector embeddings, and query them using natural language. The…

Excerpt from ResilNext'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.