Google Drive File Ingestion to Supabase for Knowledge Base RAG - n8n Workflow

Automate RAG knowledge base creation using this powerful n8n workflow. Ingest files from Google Drive, create OpenAI embeddings, and store them in Supabase Vector Store.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Developers building internal knowledge bases using RAG architecture.
Data engineers needing reliable, automated file ingestion pipelines.
Businesses requiring up-to-date document indexing without manual intervention.
Users looking for advanced n8n templates integrating cloud storage, databases, and AI.

Overview

Managing a scalable Retrieval-Augmented Generation (RAG) system requires a robust data ingestion pipeline. This comprehensive n8n workflow addresses the challenge of keeping your knowledge base current by automatically monitoring a Google Drive folder. Every new file or update detected by the n8n trigger is downloaded, validated against duplicates, extracted based on file type (PDF, DOCX, CSV, etc.), summarized, embedded using OpenAI, and finally indexed in a Supabase Vector Store. This advanced n8n node combination ensures that your AI agents always have access to the latest, relevant information. By utilizing this detailed n8n workflow, you minimize manual overhead and maximize data freshness for your AI applications.

How it Works

This complex n8n workflow operates in two main phases: Ingestion and Querying.

1. Ingestion (Triggered by Google Drive):
The process starts with two specialized n8n triggers: File Created or Update to File in Google Drive.
The Loop Over Items node processes files one by one, setting the necessary file metadata (Set File ID).
The Validate File node checks file types and structure before proceeding.
A crucial step is Check for Duplicates (Postgres node). If a file with the same ID already exists, the n8n workflow logs the duplicate (Log Duplicate) and sends a notification (Slack Duplicate Notification).
If the file is new or updated, the n8n workflow uses Supabase nodes (Delete old Doc, Delete Old Data Rows) to clean up previous versions, ensuring data integrity. It then logs debug data using a Set n8n node.
The Download File node pulls the content from Google Drive.
The Switch n8n node routes the file based on its mime type (e.g., PDF, TXT, CSV) to the appropriate content extraction n8n node.
Content is aggregated, summarized (Summarize), and prepared for vectorization.
The LangChain components take over: The content is chunked (Character Text Splitter), loaded (Default Data Loader), and transformed into vectors using the Embeddings OpenAI n8n node.
Finally, the vectors are persisted in the Supabase Vector Store n8n node, completing the RAG index update.

2. Querying (AI Agent Interaction):
A separate path is initiated by the When chat message received n8n trigger (LangChain Chat Trigger).
The RAG AI Agent node orchestrates the query, utilizing the OpenAI Chat Model (LLM), Postgres Chat Memory (to maintain conversation context), and specialized database tools (List Documents, Query Document Rows, Get Full Document Text) to retrieve relevant information from the Supabase RAG index, ensuring accurate responses based on the ingested documents. This query path demonstrates the power of the end-to-end n8n workflow setup.

Installation Guide


  1. Import the n8n workflow: Copy the provided JSON and import it into your n8n instance via the Workflows section -> New -> Import From JSON.

  2. Credential Setup:

Google Drive: Configure the Google Drive credentials for the File Created and Update to File n8n trigger nodes, ensuring n8n has access to the target folder.
Postgres/Supabase: Set up credentials for the numerous Postgres and Supabase n8n node instances (e.g., Check for Duplicates, Insert Metadata, Supabase Vector Store). You will need the connection details for your metadata and vector tables.
OpenAI: Configure your OpenAI API Key for the Embeddings OpenAI n8n node and the OpenAI Chat Model within the RAG Agent. This is essential for the AI part of the n8n templates.
Notifications (Optional): Update the Slack Duplicate Notification and Error Notification nodes with valid Gmail or Slack credentials if you wish to receive alerts.

  1. Database Schema: Ensure your Supabase/Postgres database has the required tables for metadata storage and vector storage, as expected by the Postgres n8n node operations. Follow best practices for RAG schema setup.

  2. Activate: Save and activate the n8n workflow. The Google Drive n8n trigger will begin polling the folder.

Node Details

Google Drive Trigger (File Created / Update to File): These are the core n8n trigger nodes that start the ingestion process when a file event occurs in the monitored folder.
Postgres n8n node (Check for Duplicates): Queries the metadata table to determine if the document ID already exists, preventing redundant processing within this n8n workflow.
Google Drive n8n node (Download File): Fetches the actual binary content of the file from Google Drive, required before extraction.
Switch n8n node: A flow control node that routes the file data based on MIME type to the correct content extraction n8n node (e.g., PDF, TXT, CSV, DOCX).
Extract from File n8n node (Multiple Instances): Specialized n8n nodes for parsing content out of binary files (like Extract from File PDF, Extract from TXT).
Embeddings OpenAI n8n node: Generates high-quality vector embeddings using the OpenAI API for the document chunks.
Supabase Vector Store n8n node: The final step in the ingestion pipeline. This n8n node handles inserting the embeddings into the configured Supabase (pgvector) database.
Chat Trigger n8n trigger (When chat message received): Initiates the interactive AI query path of the n8n workflow, allowing users to communicate with the knowledge base.


  • RAG AI Agent n8n node: The intelligent core for querying. This composite n8n node leverages the LLM (OpenAI Chat Model), chat history (Postgres Chat Memory), and the Supabase Vector Store2 tool for effective RAG functionality.

Related n8n Workflows

Paid

Nodes: 22 Nodes
Updated: December 26 2025
View all
Created by
Immanuel
Immanuel

Featured*