Incremental Supabase Storage to pgvector file RAG chat workflow
This n8n workflow lists files inside a private Supabase Storage bucket and compares them against records already logged in your Supabase files table. Only new uploads loop through TXT or PDF extraction, split into 500-character chunks and upsert into pgvector with file_id metadata for top-8 chat retrieval.
- Catalogue ID
- #1246
- Functional nodes
- 22
- Connections
- 23
- Trigger
- manualTrigger, chatTrigger
- AI layer
- AI-assisted
Business problem solved
Re-indexing an entire document bucket whenever one new file lands wastes embedding tokens and creates duplicate chunks. Teams storing documents in Supabase need incremental detection before writing to pgvector.
Trigger
A manual trigger syncs new Supabase Storage files into pgvector; a chat trigger serves RAG questions.
Connected systems
- Supabase Storage API
- Supabase PostgreSQL and pgvector
- PDF and text extraction
- OpenAI
- Chat interface
- Self-hosted n8n
Every workflow is deployed on your own server with documentation, a run log and an error queue.
Workflow architecture
- 1. Get All files (Service and data) (connects to Loop Over Items)
- 2. Default Data Loader (AI layer) (connects to Insert into Supabase…)
- 3. Recursive Character Text… (AI layer) (connects to Default Data Loader)
- 4. Extract Document PDF (Service and data) (connects to Merge)
- 5. Embeddings OpenAI (AI layer) (connects to Insert into Supabase…)
- 6. Create File record2 (Service and data) (connects to Insert into Supabase…)
- 7. If (Logic and routing) (connects to Download, Loop Over Items)
- 8. Get All Files (Service and data) (connects to Aggregate)
- 9. Download (Service and data) (connects to Switch)
- 10. Loop Over Items (Logic and routing) (connects to If)
- 11. When clicking Test workflow (Trigger) (connects to Get All Files)
- 12. Aggregate (Logic and routing) (connects to Get All files)
- 13. When chat message received (Trigger) (connects to AI Agent)
- 14. OpenAI Chat Model1 (AI layer) (connects to AI Agent)
- 15. Embeddings OpenAI2 (AI layer) (connects to Supabase Vector Store)
- 16. OpenAI Chat Model2 (AI layer) (connects to Vector Store Tool1)
- 17. Vector Store Tool1 (AI layer) (connects to AI Agent)
- 18. Switch (Logic and routing) (connects to Merge, Extract Document PDF)
- 19. Insert into Supabase… (AI layer) (connects to Loop Over Items)
- 20. Merge (Logic and routing) (connects to Create File record2)
- 21. AI Agent (AI layer)
- 22. Supabase Vector Store (AI layer) (connects to Vector Store Tool1)
- Trigger
- AI layer
- Logic and routing
- Service and data
Node positions and directed links are generated from the verified catalogue record.
Workflow steps
- 01
Storage bucket and table diff
HTTP lists bucket objects and compares them against the Supabase files table so already-indexed files are skipped.
- 02
File logging and format switch
Each new object registers in the files table while a switch node routes TXT and PDF payloads separately.
- 03
Chunking and pgvector metadata insert
Extracted text splits into 500-character chunks tagged with file_id metadata and inserts into the pgvector documents table.
- 04
Top-8 knowledge base chat
Chat enquiries invoke the AI agent with the Supabase knowledge_base tool retrieving the eight closest chunks.
Error queue and human approval
Built-in state in the catalogue workflow
The verified catalogue workflow contains zero node-level error flags, while its table-comparison branch prevents duplicate re-indexing by design.
Production layer added by ALTAI
During live deployment, ALTAI adds scheduled or storage-webhook triggers, rollback cleanup if vector insertion fails after logging, row-level security filters and an error queue.
Supabase Storage and pgvector RAG Frequently asked questions
No. Comparing the Storage listing against the Supabase files table filters out previously processed files.
Every chunk stores file_id metadata, allowing a single delete query against the documents table whenever a source file is removed.
Yes. Adding extra branches on the file-extension switch node handles Markdown, CSV or DOCX documents cleanly.
Related n8n workflows
Pinecone cited structured RAG
Tags Google Drive documents with file metadata in Pinecone, retrieves numbered chunks and enforces structured citations mapped back to source URLs.
Milvus and Cohere Drive RAG agent
Watches Google Drive for new PDFs, extracts text, stores multilingual Cohere embeddings in Milvus and answers questions with OpenAI gpt-4o.
Drive and Pinecone Gemini RAG workflow
Tracks created and updated Google Drive files, embeds chunks with Google Gemini into Pinecone and serves grounded team chat answers.

We write the proposal after we have found the problem together
In a thirty-minute call we listen to how you work and talk through where time and customers are slipping away. If you do not need a digital fix, we will tell you that too.
30 minutes · no preparation needed
The call and the week of discovery are both free.Read the terms