Build an AI Agent in n8n: Chat with Files from Supabase Storage and Google Drive
Automatically vectorize documents from a Supabase private bucket or Google Drive folder, then query them through an AI agent with natural-language Q&A
- Who
- Developers, data analysts, or business users with basic n8n and database experience who need AI-powered Q&A over document repositories
- You get
- Files are auto-parsed, chunked, embedded, and stored as vectors; users chat via a chat interface or webhook for context-aware answers grounded in uploaded documents
- You need
- n8n · supabase · google-drive · llamaparse
Constraints
Prerequisites: an n8n instance (self-hosted or cloud); a Supabase project with API credentials (supabaseApi); an OpenAI API key (openAiApi); Google Drive OAuth2 credentials (googleDriveOAuth2Api); a LlamaParse API key (httpHeaderAuth). Create a private Supabase bucket and files/documents tables with vector matching enabled. Costs: OpenAI embedding and chat models billed by token; LlamaParse billed by page; Supabase billed by storage and DB usage.
What they did
Author Mark Shcherbakov published a 62-node workflow on the n8n template library integrating Supabase Storage, Google Drive, LlamaParse, and OpenAI to automate three scenarios: batch-importing files from a Supabase bucket into a vector store, providing AI Q&A over documents via Chat Trigger or Webhook, and monitoring a Google Drive folder to auto-sync new or updated files. The workflow uses Recursive Character Text Splitter (chunkSize=500, chunkOverlap=200) with OpenAI text-embedding-3-small for embeddings, stores vectors in a Supabase pgvector table, and configures the AI Agent with a system-level instruction mandating knowledge-base-grounded responses.
How it went
The author reports this workflow reduces manual effort for cross-platform file management, enabling automated document parsing and interactive AI retrieval (author_report). The template has received 9,397 views on n8n.io. A video guide (YouTube) demonstrates the full setup process.
Worth knowing
1. The workflow contains a hardcoded example Google Drive folder ID (1rFIHlWMlbt0vAh1CWjcmNOmJYk_8jUIb) that must be replaced for production use. 2. LlamaParse parsing failures trigger the Stop and Error node, halting execution; monitor error outputs accordingly. 3. Two Wait nodes (7-second delay) throttle LlamaParse API calls to avoid service limits. 4. The source does not provide specific SQL table definitions or the match_documents function implementation; users must prepare these or consult Supabase vector extension documentation. 5. This site has not executed the workflow (reproduction=not_tested); step descriptions are derived from template structure and node parameters, and actual setup may require adjustments for n8n version differences.
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
- httpRequest node: connect HTTP/API keys per node headers or query params.
- embeddingsOpenAi node: connect OpenAI API credentials.
- supabase node: connect Supabase URL + Service Key.
- vectorStoreSupabase node: connect Supabase URL + Service Key.
- lmChatOpenAi node: connect OpenAI API credentials.
- googleDriveTrigger node: connect Google Drive OAuth2 credentials.
- googleDrive node: connect Google Drive OAuth2 credentials.
Configuration to replace
- Source template is n8n public workflow #4086 (~62 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-24
Steps
Create Supabase bucket and upload files
Create a private bucket in your Supabase project, modifying the default name as needed. Upload document files to this bucket using the provided upload options. This bucket serves as one of the primary file sources for the workflow.
Configure database tables and vector extension
Create a files table (tracking file names and storage IDs) and a documents table (storing vectorized document chunks) in Supabase. Execute the necessary SQL queries to enable vector matching capabilities (e.g., pgvector extension and a match_documents query function).
Import workflow and replace credentials
Import this workflow from the n8n template library (template ID 4086). Review all credential placeholders across nodes and replace them with your own: supabaseApi (Supabase project URL and service-role key), openAiApi (OpenAI API key), googleDriveOAuth2Api (Google Drive OAuth2 client credentials), and httpHeaderAuth (LlamaParse API key, formatted as Authorization: Bearer <api_key>). Update the <project_id> placeholder in HTTP Request nodes to your actual Supabase project ID.
Setup guidance · Editorial suggestion。Setup assistant checklist; verify credentials and project ID replacement before execution
Please check all sticky notes marked ### Replace credentials. and ensure the following credentials are correctly configured: 1. supabaseApi - Supabase project URL and service-role key 2. openAiApi - OpenAI API key 3. googleDriveOAuth2Api - Google Drive OAuth2 client credentials 4. httpHeaderAuth - LlamaParse API key (Header: Authorization: Bearer <api_key>) Also replace <project_id> in all HTTP Request nodes with your actual Supabase project ID.
Configure Google Drive monitoring trigger
In the Scenario 3 branch of the workflow, configure the Google Drive Trigger nodes (File Created / File Updated) to watch a specific Google Drive folder. Replace the example folder ID in folderToWatch with your actual target folder ID. Set the polling interval (default: every minute). When new files are created or updated, the workflow automatically downloads and processes them.
Configure the AI agent chat interface
In the Scenario 2 branch, configure the AI Agent node's system prompt and model parameters. The AI Agent accepts input via Chat Trigger (When chat message received) or Webhook. Select gpt-4o-mini or gpt-4o in the OpenAI Chat Model node. Configure the Simple Memory node to use a custom session key (from the Merge node's session_id) to maintain conversation context across turns.
Execution prompt · Source text。AI Agent1 node systemMessage field; defines agent behavioral constraint
You are a helpful assistant. IMPORTANT Always use knowledge base to respond users.
Configure vector store and memory persistence
Set the Supabase Vector Store node to retrieve-as-tool mode, connecting to the documents table with tool name knowledge_base and description Gather facts from knowledge base to respond user.. Configure both Insert into Supabase Vectorstore nodes (for Scenario 1 and 3) to use the text-embedding-3-small model with chunkSize 500 and chunkOverlap 200. Simple Memory uses PostgreSQL to store user interactions and manage conversation states.
Test and fine-tune
After configuration, use the manual trigger (When clicking 'Test workflow') to test the Scenario 1 file processing flow, verifying that files download, parse, vectorize, and insert correctly. Send test messages via Chat Trigger or Webhook to verify the AI Agent returns relevant answers grounded in stored documents. Adjust model parameters, chunk size, or the system prompt based on response quality.
Prompt you can copy
Setup guidance · Editorial suggestion。Hand to setup assistant to confirm inputs and permissions before proceeding with tests
This block is the prompt. Ads are never placed here.
You are assisting with reproducing an n8n workflow template: an AI file-Q&A agent powered by Supabase and Google Drive. Confirm prerequisites in this order: 1) Supabase project, private bucket, files/documents tables, and vector extension are ready; 2) Four credentials (supabaseApi, openAiApi, googleDriveOAuth2Api, httpHeaderAuth) are obtained and configured; 3) Workflow JSON is imported and all <project_id> and folder IDs are replaced with actual values; 4) LlamaParse API key is set in HTTP Header Auth. Once confirmed, execute each scenario step by step.
Placeholders to replace: Supabase project_id, Google Drive folder ID, all credential IDs. Recommend testing Scenario 1 with a single file first, then validating Scenario 2 chat responses.
Source
Ai agent to chat with files in Supabase Storage and Google Drive · lowcodingdev · n8n.io · 2025-05-15
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.