π Sync Supabase Storage files into a chat agent with Supabase vectors and OpenAI
β‘ 2 views Β· π Internal Wiki & Knowledge Base
Description
Quick overview
This workflow syncs files from Supabase Storage into a Supabase vector store using OpenAI embeddings, then exposes an n8n chat trigger where an AI agent answers questions by retrieving relevant document chunks from Supabase.
How it works
- Starts a manual sync run when you click βTest workflowβ.
- Reads existing file records from the Supabase
filestable and lists objects in the Supabase Storageprivatebucket. - Compares both lists and skips files that are already indexed or match the
.emptyFolderPlaceholdermarker. - Downloads each new file from Supabase Storage and extracts text (PDFs are parsed; files without an extension are treated as plain text).
- Creates a new row in the Supabase
filestable and splits the extracted text into chunks. - Generates embeddings with OpenAI and inserts the chunks into the Supabase
documentsvector table for later retrieval. - When a chat message is received, an AI agent uses OpenAI and a Supabase vector search tool to retrieve the top matches and respond with answers grounded in the indexed files.
Setup
- Add a Supabase API credential and replace the hardcoded Supabase project URL used by the Storage list and download requests.
- Create the Supabase
filestable (at leastnameandstorage_id) and adocumentsvector table plus thematch_documentsfunction required by the Supabase vector store integration. - Add OpenAI credentials for the embeddings model and chat models used by the indexing and chat steps.
- Update or remove the hardcoded
file_idmetadata filter in the Supabase vector search so the chat agent searches across all indexed documents (or set it to the file you want to limit results to). - If you plan to index non-PDF text uploads, add a text extraction/reading step for the βtxtβ branch so plain files produce text for chunking and embedding.
π Nodes Used
HTTP Request, Supabase, AI Agent, Embeddings OpenAI, OpenAI Chat Model, Recursive Character Text Splitter
π₯ Import
Download workflow.json and import into n8n:
Workflow menu β Import from File