Skip to main content

AI agent to chat with files in Supabase Storage

Workflow preview

Workflow preview
100%
AI agent to chat with files in Supabase Storage preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

Video Guide I prepared a detailed guide explaining how to set up and implement this scenario, enabling you to chat with your documents stored in Supabase using n8n. [![Youtube Thumbnail](https://re...

Best for

  • Internal Wiki automation workflows
  • AI RAG automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.httprequest, @n8n/n8n-nodes-langchain.documentdefaultdataloader, @n8n/n8n-nodes-langchain.textsplitterrecursivecharactertextsplitter, n8n-nodes-base.extractfromfile, @n8n/n8n-nodes-langchain.embeddingsopenai, n8n-nodes-base.supabase, n8n-nodes-base.if, n8n-nodes-base.splitinbatches

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Mark Shcherbakov.

Original n8n.io source

1.1 Workflow description

Title
AI agent to chat with files in Supabase Storage
Workflow name
AI agent to chat with files in Supabase Storage

Video Guide

I prepared a detailed guide explaining how to set up and implement this scenario, enabling you to chat with your documents stored in Supabase using n8n.

Youtube Link

Who is this for?

This workflow is ideal for researchers, analysts, business owners, or anyone managing a large collection of documents. It's particularly beneficial for those who need quick contextual information retrieval from text-heavy files stored in Supabase, without needing additional services like Google Drive.

What problem does this workflow solve?

Manually retrieving and analyzing specific information from large document repositories is time-consuming and inefficient. This workflow automates the process by vectorizing documents and enabling AI-powered interactions, making it easy to query and retrieve context-based information from uploaded files.

What this workflow does

The workflow integrates Supabase with an AI-powered chatbot to process, store, and query text and PDF files. The steps include:

  • Fetching and comparing files to avoid duplicate processing.
  • Handling file downloads and extracting content based on the file type.
  • Converting documents into vectorized data for contextual information retrieval.
  • Storing and querying vectorized data from a Supabase vector store.
  1. File Extraction and Processing: Automates handling of multiple file formats (e.g., PDFs, text files), and extracts document content.
  2. Vectorized Embeddings Creation: Generates embeddings for processed data to enable AI-driven interactions.
  3. Dynamic Data Querying: Allows users to query their document repository conversationally using a chatbot.

Setup

N8N Workflow
  1. Fetch File List from Supabase:

    • Use Supabase to retrieve the stored file list from a specified bucket.
    • Add logic to manage empty folder placeholders returned by Supabase, avoiding incorrect processing.
  2. Compare and Filter Files:

    • Aggregate the files retrieved from storage and compare them to the existing list in the Supabase files table.
    • Exclude duplicates and skip placeholder files to ensure only unprocessed files are handled.
  3. Handle File Downloads:

    • Download new files using detailed storage configurations for public/private access.
    • Adjust the storage settings and GET requests to match your Supabase setup.
  4. File Type Processing:

    • Use a Switch node to target specific file types (e.g., PDFs or text files).
    • Employ relevant tools to process the content:
      • For PDFs, extract embedded content.
      • For text files, directly process the text data.
  5. Content Chunking:

    • Break large text data into smaller chunks using the Text Splitter node.
    • Define chunk size (default: 500 tokens) and overlap to retain necessary context across chunks.
  6. Vector Embedding Creation:

    • Generate vectorized embeddings for the processed content using OpenAI's embedding tools.
    • Ensure metadata, such as file ID, is included for easy data retrieval.
  7. Store Vectorized Data:

    • Save the vectorized information into a dedicated Supabase vector store.
    • Use the default schema and table provided by Supabase for seamless setup.
  8. AI Chatbot Integration:

    • Add a chatbot node to handle user input and retrieve relevant document chunks.
    • Use metadata like file ID for targeted queries, especially when multiple documents are involved.

Testing

  • Upload sample files to your Supabase bucket.
  • Verify if files are processed and stored successfully in the vector store.
  • Ask simple conversational questions about your documents using the chatbot (e.g., "What does Chapter 1 say about the Roman Empire?").
  • Test for accuracy and contextual relevance of retrieved results.

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Get All files

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 2 - Default Data Loader

Type / Role
@n8n/n8n-nodes-langchain.documentDefaultDataLoader - documentDefaultDataLoader
Config choices
Version 1

Block 3 - Recursive Character Text Splitter

Type / Role
@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter - textSplitterRecursiveCharacterTextSplitter
Config choices
Version 1

Block 4 - Extract Document PDF

Type / Role
n8n-nodes-base.extractFromFile - extractFromFile
Config choices
Version 1

Block 5 - Embeddings OpenAI

Type / Role
@n8n/n8n-nodes-langchain.embeddingsOpenAi - embeddingsOpenAi
Config choices
Version 1

Block 6 - Create File record2

Type / Role
n8n-nodes-base.supabase - supabase
Config choices
Version 1

Block 7 - If

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 8 - Get All Files

Type / Role
n8n-nodes-base.supabase - supabase
Config choices
Version 1

Block 9 - Download

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 10 - Loop Over Items

Type / Role
n8n-nodes-base.splitInBatches - splitInBatches
Config choices
Version 3

Block 11 - When clicking ‘Test workflow’

Type / Role
n8n-nodes-base.manualTrigger - manualTrigger
Config choices
Version 1

Block 12 - Aggregate

Type / Role
n8n-nodes-base.aggregate - aggregate
Config choices
Version 1

Block 13 - When chat message received

Type / Role
@n8n/n8n-nodes-langchain.chatTrigger - chatTrigger
Config choices
Version 1.1

Block 14 - OpenAI Chat Model1

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenAi - lmChatOpenAi
Config choices
Version 1

Block 15 - Embeddings OpenAI2

Type / Role
@n8n/n8n-nodes-langchain.embeddingsOpenAi - embeddingsOpenAi
Config choices
Version 1

Block 16 - OpenAI Chat Model2

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenAi - lmChatOpenAi
Config choices
Version 1

Block 17 - Vector Store Tool1

Type / Role
@n8n/n8n-nodes-langchain.toolVectorStore - toolVectorStore
Config choices
Version 1

Block 18 - Switch

Type / Role
n8n-nodes-base.switch - switch
Config choices
Version 3.1

Block 19 - Insert into Supabase Vectorstore

Type / Role
@n8n/n8n-nodes-langchain.vectorStoreSupabase - vectorStoreSupabase
Config choices
Version 1

Block 20 - Merge

Type / Role
n8n-nodes-base.merge - merge
Config choices
Version 3

Block 21 - AI Agent

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 1.7

Block 22 - Supabase Vector Store

Type / Role
@n8n/n8n-nodes-langchain.vectorStoreSupabase - vectorStoreSupabase
Config choices
Version 1

Block 23 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 24 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Showing the first 24 of 33 workflow blocks. Download the JSON for the full node graph.

3. Summary Table

Workflow AI agent to chat with files in Supabase Storage
Complexity advanced
Nodes 33
Categories Internal Wiki, AI RAG
Author Mark Shcherbakov
Published 10 Dec 2024

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/2621/2621.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does AI agent to chat with files in Supabase Storage do?

Video Guide I prepared a detailed guide explaining how to set up and implement this scenario, enabling you to chat with your documents stored in Supabase using n8n. [![Youtube Thumbnail](https://re...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Internal Wiki, AI RAG use case.