n8n

How to Automate Supabase Document Q and A?

Turn your file storage into a searchable chat. Team members ask a question and get answers pulled from your own documents. Great for support and operations that keep files in Supabase.

The flow lists files in a Supabase bucket, compares them with a files table, and skips duplicates. New items are downloaded and routed by type. Text files go straight to processing while PDFs are extracted first. Content is split into chunks of about 500 tokens with overlap to keep context. OpenAI embeddings are created and stored in a Supabase vector store with file_id metadata. A chat trigger listens for questions and an AI agent pulls the top 8 matching chunks to answer in plain language.

You need a Supabase project with storage and a vector store table, plus an OpenAI API key. Update the Supabase URLs, bucket path, and credentials in the nodes. Expect faster answers, less manual search, and scalable knowledge across many files. Use it for policy search, help desk articles, onboarding guides, and sales materials that need quick, accurate answers.

What are the key features?

  • Two triggers: a manual test run and a chat message event
  • Lists Supabase objects and compares with a files table to avoid reprocessing
  • Downloads files from a private bucket using authenticated requests
  • Routes by file type so text and PDF are handled correctly
  • Extracts text from PDFs before processing
  • Splits content into 500 token chunks with 200 overlap to preserve context
  • Creates embeddings with OpenAI for vector search
  • Inserts vectors into a Supabase vector store with a match query
  • AI agent retrieves the top 8 relevant chunks and answers with context
  • Tags every chunk with file_id to support focused queries

What are the benefits?

  • Reduce manual document search from hours to minutes
  • Automate up to 90 percent of document lookups
  • Improve answer accuracy by pulling exact source text
  • Handle 10 times more files without extra staff
  • Connect Supabase storage and OpenAI in one flow
  • Skip duplicates to keep storage and vectors clean

How do you set it up?

  1. Import the template into n8n: Create a new workflow in n8n > Click the three dots menu > Select 'Import from File' > Choose the downloaded JSON file.
  2. You'll need accounts with Supabase and OpenAI. See the Tools Required section above for links to create accounts with these services.
  3. In your Supabase project, create or select a storage bucket and upload a few PDF or text files for testing.
  4. Ensure your database has a vector store table and a match function that the vector store node can call. If needed, follow your Supabase docs to enable the vector extension.
  5. In the n8n credentials manager, create a Supabase credential. Use your project URL and a Service Role key for write access. Name it clearly and save.
  6. In the n8n credentials manager, create an OpenAI credential. Generate an API key in your OpenAI account and paste it into n8n. Save the credential.
  7. Open the HTTP Request node that lists objects and replace the project URL and bucket path with your Supabase details. Do the same for the Download node.
  8. Open the Supabase nodes and select your Supabase credential. Confirm the files table name and field mappings match your database schema.
  9. Review the Switch node and make sure it routes the file types you store. Add rules for other formats if needed.
  10. Check the text splitter settings. Keep the default 500 size and 200 overlap, or adjust if your documents are very long or very short.
  11. Run the manual trigger to process your initial files. Verify new rows in the files table and confirm vectors were inserted into the vector store.
  12. Use the chat interface connected to the chat trigger and ask a question about your documents. You should get an answer backed by relevant chunks.
  13. Troubleshooting: 401 errors mean the Supabase key or URL is wrong. Empty answers often mean no vectors were created. If PDFs fail, check the extractor node and file access.

Tools Required

$24 / mo or $20 / mo billed annually to use n8n in the cloud. However, the local or self-hosted n8n Community Edition is free.

OpenAI

Sign up

Pay-as-you-go: GPT-5 at $1.25 per 1M input tokens and $10 per 1M output tokens

Supabase

Sign up

Free: $0 / mo — unlimited API requests; 500 MB database; 5 GB bandwidth; 1 GB storage; 50,000 MAUs.

Credits:
Created by Mark Shcherbakov from 5minAI. Tutorial: YouTube video

Similar Templates

Join Futurise to access 1,200+ automation templates

Get instant access to ready-made automation workflows for n8n, Make.com, AI agents, and more. Download, customise, and deploy in minutes.