Multi-Client Agentic RAG Document Processing Pipeline with Supabase Vector DB - n8n Workflow

Deploy a robust, multi-tenant RAG pipeline using n8n to monitor Google Drive, process various documents (PDF, Excel, Docs), generate OpenAI embeddings, and securely store data in client-specific Supabase vector databases. This advanced n8n workflow ensures data isolation for enterprise clients.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Technical teams and developers building secure, scalable RAG applications.

  • Consultants needing to manage isolated knowledge bases for multiple enterprise clients.

  • Data engineers implementing automated document ingestion pipelines using n8n.

  • Users looking for advanced n8n templates integrating Google Drive, OpenAI, and Supabase.

Overview

This sophisticated automation represents an enterprise-grade solution for building multi-client knowledge bases. The primary challenge this n8n workflow solves is data isolation: each client's documents must be processed and stored separately to ensure confidentiality.

This n8n template starts with a unique initialization phase where specific PostgreSQL tables and custom vector match functions are created per client, based on a manual trigger. Once the infrastructure is set up, the core pipeline uses dedicated n8n trigger nodes to monitor Google Drive folders for new or updated files. It intelligently handles PDFs, spreadsheets (Excel, CSV), and text documents (Google Docs), extracting content and schema information. The data is then transformed, chunked using the Character Text Splitter n8n node, and embedded using OpenAI. Finally, the resulting vectors are securely inserted into the designated client's Supabase vector database, completing the robust RAG ingestion process. This complex n8n workflow showcases the power and flexibility of n8n in handling complex, multi-tenant AI operations.

How it Works

The entire process is divided into two major phases within this n8n workflow:


  1. Client Setup (Manual Trigger): The workflow starts with the 'When chat message received' n8n trigger (used for initialization). This sequence executes several PostgreSQL n8n node operations to dynamically create client-specific tables: [client]documents (vector store), [client]documentmetadata, and [client]document_rows, ensuring complete data separation from the start.


  1. Document Ingestion (Automatic Trigger): The pipeline is primarily activated by the 'File Created' or 'File Updated' Google Drive n8n trigger nodes, monitoring a specific client folder.

Upon activation, the 'Loop Over Items' n8n node processes each file and the 'Set File ID' n8n node extracts critical metadata.
Supabase n8n node operations delete any existing vector or metadata entries for that file, ensuring idempotency.
The document is downloaded, and the 'Switch' n8n node directs the flow based on file type (PDF, Excel, CSV, or general text).
Tabular data (Excel/CSV) goes through aggregation and summarization, and both the schema and raw row data are stored separately in dedicated Postgres tables using the Postgres n8n node.
All extracted text streams converge. An 'Embeddings OpenAI' n8n node generates the vector representation using text-embedding-3-small.
The 'Character Text Splitter' n8n node chunks the content, which is then loaded with metadata using the 'Default Data Loader' n8n node.
* The final step uses the 'Insert into Supabase Vectorstore' n8n node to persist the documents, vectors, and metadata into the correct client's table, making the content instantly searchable via RAG queries.

Installation Guide


  1. Import: Copy the provided n8n workflow JSON and import it into your n8n instance.

  2. Credentials: You will need to configure the following credentials:

Google Drive OAuth2: For the Google Drive n8n trigger and 'Download File' n8n node.
OpenAI API Key: For the 'Embeddings OpenAI' n8n node.
Postgres Account - Clients: Used for the initial setup nodes (Phase 1) to dynamically create client tables.
Postgres Account - IDR: Used for the ingestion nodes (Phase 2) to store document metadata and tabular data rows.
Supabase API: For the vector store operations, connecting to your Supabase instance.

  1. Customization: Review the following critical configuration steps:

Triggers: Update the folder URL in both Google Drive n8n trigger nodes ('File Created' and 'File Updated') to point to your desired client monitoring folder.
* Supabase Node: Crucially, update the 'Insert into Supabase Vectorstore' n8n node and the related deletion n8n nodes to reference the specific client table name (e.g., change documents to [clientname]documents) that was created during the setup phase. This is vital for maintaining data isolation in this n8n workflow.

Node Details

File Created / File Updated (Google Drive Trigger): These n8n trigger nodes monitor a specified Google Drive folder for new or modified files. This is the primary entry point for document ingestion in this n8n workflow.
Set File ID (Set n8n node): Captures essential metadata from the Google Drive item, including fileid, filetype, and file_title, crucial for subsequent filtering and storage operations.
Download File (Google Drive n8n node): Fetches the actual binary content of the file from Google Drive.
Switch (n8n node): Routes the flow based on the file's MIME type (e.g., application/pdf, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet).
Extract from File (n8n node): A set of nodes ('Extract PDF Text', 'Extract from Excel', 'Extract from CSV', 'Extract Document Text') responsible for converting binary files into structured or plain text ready for the AI pipeline.
Summarize (n8n node): Used here to concatenate data from tabular formats into a single, comprehensive text field for vectorization.
Embeddings OpenAI (n8n node): The core AI component. Generates 1536-dimensional semantic vector embeddings using the text-embedding-3-small model.
Character Text Splitter (n8n node): Chunks the long documents into smaller segments optimized for RAG retrieval.


  • Insert into Supabase Vectorstore (n8n node): The final action, responsible for storing the generated vector embeddings and associated metadata into the isolated, client-specific Supabase table. This critical n8n node completes the ingestion cycle.

Related n8n Workflows

Free

Nodes: 16 Nodes
Updated: December 26 2025
View all
Created by

Featured*