Maintain RAG embeddings with OpenAI, Postgres and auto drift rollback
Ready for 3.0What this workflow does
This AI workflow has 27 nodes and runs on a schedule (every day at 02:00) (plus 1 other trigger). Along the way it connects Postgres, Embeddings OpenAI and OpenAI Chat Model.
How it runs
Trigger: On a schedule (every day at 02:00) (plus 1 other trigger).
- Workflow Configuration (Edit Fields (Set)): sets 6 fields: documentSourceUrl, chunkSize, chunkOverlap…
- Fetch Documents from Source (HTTP Request): calls an HTTP API
- Fetch Previous Chunk Hashes (Postgres): run a query
- Chunk Documents & Compute Hash (Code): runs custom JavaScript code
- Detect Changed Chunks (Compare Datasets): uses Compare Datasets
- New Vector Store (Candidate) (Simple Vector Store): stores documents in the Simple vector store, with embeddings: OpenAI Embeddings; document loader: Document Loader
- Store Embedding Metadata (Code): runs custom JavaScript code
- Save Embedding Version Metadata (Postgres): uses Postgres
- Fetch Golden Questions (Postgres): run a query
- Fetch Previous Embeddings (Postgres): run a query
…plus 9 more steps. See the full node list below.
Services it uses
Other OpenAI + PostgreSQL templates (191)
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.
- Code node: the task timeout drops from 300s to 60s. Test with a realistic data volume.
Nodes used (14)
- Schedule Trigger
n8n-nodes-base.scheduleTrigger - Webhook
n8n-nodes-base.webhook - Edit Fields (Set)
n8n-nodes-base.set - HTTP Request
n8n-nodes-base.httpRequest - Code
n8n-nodes-base.code - Postgres
n8n-nodes-base.postgres - Compare Datasets
n8n-nodes-base.compareDatasets - Embeddings OpenAI
@n8n/n8n-nodes-langchain.embeddingsOpenAi - Recursive Character Text Splitter
@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter - Default Data Loader
@n8n/n8n-nodes-langchain.documentDefaultDataLoader - Simple Vector Store
@n8n/n8n-nodes-langchain.vectorStoreInMemory - OpenAI Chat Model
@n8n/n8n-nodes-langchain.lmChatOpenAi - If
n8n-nodes-base.if - AI Agent
@n8n/n8n-nodes-langchain.agent
From the author
Overview This workflow implements a self-healing Retrieval-Augmented Generation (RAG) maintenance system that automatically updates document embeddings, evaluates retrieval quality, detects embedding drift, and safely promotes or rolls back embedding updates.…