RAG Knowledge Base Assistant with Google Drive and Supabase - n8n Workflow

Build a robust AI assistant using RAG (Retrieval-Augmented Generation) in n8n. Automate syncing Google Drive documents to Supabase vector storage via an n8n workflow, powering an OpenAI chatbot capable of handling text and voice queries.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Technical teams and agencies needing an internal AI knowledge base.

  • Businesses looking to deploy automated customer support bots (SaaS).

  • Users requiring an efficient system to sync documentation updates automatically.

  • Developers searching for advanced n8n templates integrating LangChain components.

Overview

This powerful n8n workflow automates the entire lifecycle of a Retrieval-Augmented Generation (RAG) system. It solves the challenge of maintaining a current and searchable knowledge base by combining three critical processes: real-time chatbot interaction, automatic document ingestion, and dynamic document update management. By leveraging the flexibility of the n8n platform, it ensures that company documents uploaded or modified in Google Drive are instantly converted into OpenAI embeddings and indexed in Supabase. The resulting knowledge base is then queried by a specialized RAG Agent, enabling the Telegram chatbot to provide accurate, context-aware answers derived solely from the source documents. This complete n8n solution drastically reduces reliance on general LLM knowledge, providing accurate, proprietary information on demand.

How it Works

The overall n8n workflow is divided into three parallel automations:

1. RAG Chatbot (Telegram)


  1. The process starts with the Telegram n8n trigger, capturing incoming user messages.

  2. A Switch n8n node checks if the message is text or voice.

  3. If it's a voice message, a Telegram n8n node downloads the file, and an OpenAI n8n node (using Whisper) transcribes it to text.

  4. The processed text query is sent to the RAG Agent n8n node.

  5. The RAG Agent, using conversational memory (Window Buffer Memory n8n node) and the predefined MarketingLadder tool, performs a vector search against Supabase using OpenAI embeddings to retrieve relevant document chunks.

  6. An OpenAI Chat Model processes the retrieved context and generates a final answer.

  7. The final response is sent back to the user via the Response Telegram n8n node.

2. New File Sync (Ingestion)


  1. The Google Drive n8n trigger starts when a new file is created in the designated folder.

  2. A Set n8n node captures the file ID.

  3. A Google Drive n8n node downloads the file, converting Google Docs formats to plain text.

  4. The Extract from File n8n node pulls the text content.

  5. Text is loaded, split using the Recursive Character Text Splitter n8n node (Chunk Size 500), and converted into vector embeddings by the Embeddings OpenAI n8n node.

  6. Finally, the Supabase Vector Store n8n node inserts these new vectors into the knowledge base.

3. Updated File Sync (Maintenance)


  1. The Google Drive n8n trigger activates when a file is modified.

  2. A Supabase n8n node executes a delete operation, removing all existing vectors associated with the file's ID.

  3. The workflow proceeds to download, extract, split, and embed the updated content (using slightly smaller chunks for the update path).

  4. A second Supabase Vector Store n8n node inserts the fresh, updated vectors, ensuring the RAG assistant uses the latest information.

Installation Guide

To deploy this comprehensive n8n workflow template, follow these steps:


  1. Import the n8n workflow: Copy the provided JSON data and paste it into your n8n canvas using the 'New' -> 'Import from JSON' function.

  2. Configure Credentials:

OpenAI: Set up credentials for API keys. This is required for transcription, embeddings generation, and LLM completions. Ensure this credential is linked to all Embeddings OpenAI, OpenAI Chat Model, and Transcribe n8n nodes.
Supabase: Set up your Supabase API credentials, including the URL and service role key. Ensure your Supabase project has pgvector enabled and the necessary documents table configured for vector storage. Link this to all Supabase Vector Store and Supabase delete n8n nodes.
Google Drive: Authenticate your Google Drive account. This credential must be linked to both Google Drive Trigger n8n nodes and the Google Drive download n8n nodes.
Telegram: Set up a Telegram Bot token and connect it to the Telegram Trigger and Telegram response n8n nodes.

  1. Update Trigger Parameters: In the New File and File Updated n8n trigger nodes, replace the placeholder folder ID (1UHQhCrwZgZEzBIKv4LRRWtAyHbxZsg) with the ID of your actual Google Drive knowledge base folder.

  2. Activate: Once all credentials and parameters are set, activate all three segments of the n8n workflow to begin automation.

Node Details

This n8n workflow relies on a mix of core, application, and specialized LangChain n8n nodes:

Telegram Trigger: This specialized n8n trigger node initiates the RAG process upon receiving a message, handling the inbound communication.
Google Drive Trigger (New File / File Updated): These core n8n trigger nodes monitor a specific Google Drive folder, activating the synchronization flows when files are added or modified.
Google Drive (Download File): This n8n node fetches the file contents, using file conversion options to ensure text is extracted accurately from proprietary document types.
Supabase (Delete Row(s)): A critical n8n node used in the update path. It uses a dynamic filter to efficiently remove all previous vectors associated with a specific file ID before ingesting the revised content.
Extract from File: This n8n node handles the binary data from Google Drive, extracting the raw text content necessary for vectorization.
Embeddings OpenAI: The standard n8n LangChain component for vector generation, essential for creating searchable embeddings from document text.
Recursive Character Text Splitter: An n8n text splitter node that intelligently chunks documents into smaller segments optimized for vector database indexing.
Supabase Vector Store: This specialized n8n node manages the connection and data transfer to the Supabase vector database, handling both vector insertion and search operations (used via the RAG Agent).


  • RAG Agent: The central intelligence of the chat system. This LangChain n8n node orchestrates the query, memory lookup, tool selection (MarketingLadder), and final LLM response generation, defining the logic of the entire RAG n8n workflow.

Related n8n Workflows

Free

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

Hey 👋 I'm Abdul. I build AI-powered systems for marketing agencies and consultants who want to move fast and automate the boring stuff. Think lead gen agents, proposal generators, and content creation systems. I specialize in growth-focused automations and share workflows that save time and land clients.

Featured*