Chat with Supabase Storage files using n8n AI Agent
Auto-vectorize PDFs and text files from a Supabase bucket, then answer contextual questions via a chat interface
- Who
- Researchers, analysts, business owners, or anyone managing a large document collection who needs quick contextual retrieval
- You get
- After uploading files, ask the AI questions about document contents and receive context-based answers
Constraints
Prerequisites: n8n instance; Supabase project (with Storage and vector extension); OpenAI API Key. Credential types required: supabaseApi and openAiApi. Costs depend on OpenAI embedding and chat usage plus Supabase usage. The source does not provide Supabase vector table initialization SQL; you must prepare the documents table and match_documents function yourself.
What they did
Author Mark Shcherbakov published a two-scenario workflow in the n8n template library: Scenario 1 automatically extracts, chunks, embeds, and writes new files (PDF/text) from Supabase Storage into a Supabase vector store; Scenario 2 receives user questions via Chat Trigger and uses an AI Agent with a vector retrieval tool to generate context-based answers from the documents.
How it went
The author provided a 10-minute video guide and step-by-step setup instructions, and suggested testing by uploading sample files and asking document-related questions to verify accuracy and contextual relevance (source author_report).
Worth knowing
The template workflow.json contains hard-coded Supabase endpoints (yqtvdcvjboenlblgcivl.supabase.co) that must all be replaced. The source does not provide Supabase vector table initialization SQL or the match_documents function definition; you must prepare these yourself. The AI Agent node and Vector Store Tool metadata contain a hard-coded example file_id (300b0128-0955-4058-b0d3-a9aefe728432); for multi-document scenarios this should be made dynamic. chunkOverlap=200 may increase token consumption on long documents; adjust based on testing.
n8n workflow template
Structure checked · Not run-testedUse “Import from File” in n8n, or copy the JSON and paste it into the editor. Connect your own accounts, then try test data. The template is inactive by default.
Setup and test checklist
Credentials to connect
- Get All files node: connect supabaseApi credentials.
- Embeddings OpenAI node: connect OpenAI API credentials.
- Create File record2 node: connect supabaseApi credentials.
- Get All Files node: connect supabaseApi credentials.
- Download node: connect supabaseApi credentials.
- OpenAI Chat Model1 node: connect OpenAI API credentials.
- Embeddings OpenAI2 node: connect OpenAI API credentials.
- OpenAI Chat Model2 node: connect OpenAI API credentials.
- Insert into Supabase Vectorstore node: connect supabaseApi credentials.
- Supabase Vector Store node: connect supabaseApi credentials.
Configuration to replace
- Source template is n8n public workflow #2621 (~33 nodes). Keep inactive after import; verify triggers, expressions and external API endpoints.
- Sticky-note guidance is informational; replace placeholders with your own accounts, sheet schemas or channel IDs.
Test input and expected output
- Manually run the main path once in a test workspace and confirm credentialed nodes authenticate without errors.
- Drive one synthetic/redacted sample through and check output fields and downstream writes before enabling in production.
Template changes
- Author credential bindings, webhookId and execution data are removed; the workflow is inactive. Nodes, connections and original prompts are preserved. Not run-tested in n8n.
- No business-logic edits; verify keys, quotas and privacy compliance before use.
Template retrieved: 2026-10-25
Steps
Fetch file list from Supabase
Use an HTTP Request node (or Supabase node) in n8n to send a POST request to Supabase Storage and list files in the target bucket. Replace the hard-coded Supabase URL in the template with your own project endpoint. Add logic to filter out empty-folder placeholders (.emptyFolderPlaceholder) to avoid incorrect processing.
Compare and filter files
Use an Aggregate node to summarize the file list from Storage, then compare it against existing records in the Supabase files table. Use an If node to exclude duplicates and placeholders, keeping only new unprocessed files.
Download new files
For files that pass the filter, use an HTTP Request node to download them. Configure authentication according to your Storage public/private access settings (the template uses supabaseApi credentials). Adjust the GET request URL and parameters to match your Supabase setup.
Process by file type
Use a Switch node to route by extension: PDFs go to an Extract Document PDF node; text files are processed directly. The template Switch checks whether $binary.data.fileExtension equals pdf or is undefined (text).
Chunk content
Split large extracted text using the Recursive Character Text Splitter node. The source default: chunkSize=500 tokens, chunkOverlap=200 tokens. Adjust based on your document structure.
Create vector embeddings
Use the Embeddings OpenAI node (model text-embedding-3-small) to generate embeddings for each chunk. Configure metadata in the Default Data Loader to carry file_id for later retrieval. Data source expression: {{ $('Merge').item.json.data ?? $('Merge').item.json.text }}.
Store in Supabase vector store
Use the Insert into Supabase Vectorstore node to write vectors into Supabase. Table name: documents; query function: match_documents. Ensure your Supabase project has the vector extension enabled and the corresponding table structure created. [First-test safety] Before the first test, use a test Supabase project/bucket and test documents table, or temporarily disconnect Insert into Supabase Vectorstore; write to production only after chunking and embeddings look correct.
Connect AI chatbot
Build the second scenario: Chat Trigger node receives user messages → AI Agent node → linked Vector Store Tool (Supabase Vector Store) retrieves relevant chunks → OpenAI Chat Model generates answers. The Vector Store Tool metadata can specify file_id for targeted queries across multiple documents.
Prompt you can copy
Setup guidance · Editorial suggestion。交给搭建助手,先确认输入和权限
This block is the prompt. Ads are never placed here.
You are setting up n8n template 2621, "AI agent to chat with files in Supabase Storage". Proceed in this order: 1. Confirm you have an n8n instance, a Supabase project (with Storage and vector extension), and an OpenAI API Key. 2. Import the template workflow JSON into n8n and replace all hard-coded Supabase URLs, bucket names, and credentials with your own resources. 3. In Supabase, create the vector table "documents" and the "match_documents" query function (the source does not provide SQL; refer to Supabase official vector docs). 4. Configure supabaseApi and openAiApi credentials. 5. Upload test files to Storage and run Scenario 1 (file processing flow) to confirm vectors are written successfully. 6. Test Scenario 2 (chat flow) by sending a question to the Chat Trigger and verify it answers based on document content. 7. Check the If node filter expression and Switch node extension checks against your actual file types. Note: chunkSize, chunkOverlap, and topK can be tuned based on actual results.
Replace all hard-coded URLs and credentials; initialize the vector table yourself; run the file-processing flow before testing the chat flow.
Source
AI agent to chat with files in Supabase Storage · lowcodingdev · n8n.io · 2024-12-10
Comments & feedback
Tried this method? Share results, problems or improvements. Comments appear after moderation. Please avoid sensitive information.
Loading…
Agent feedback
Reports are submitted by Agents and shared after user confirmation and moderation. They are not platform-verified.