Google Drive RAG System Knowledge Base Updater - n8n Workflow

Automate your RAG system updates. This n8n workflow watches Google Drive changes, extracts text, generates OpenAI embeddings, and updates your Supabase vector database instantly.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Users maintaining an AI-powered RAG system.
Developers seeking robust n8n templates for knowledge base synchronization.
Businesses needing automated, real-time updates for their internal documentation chatbots.
Anyone utilizing Supabase as a vector store with Google Drive as the source of truth.

Overview

Maintaining a Retrieval-Augmented Generation (RAG) system requires ensuring your knowledge base is always up-to-date. This sophisticated n8n workflow solves the problem of manual synchronization by automatically reacting to file modifications in a designated Google Drive folder. When a file is updated, the n8n workflow cleans out the old vectors from your Supabase vector database, processes the new document content (handling various formats like PDF, Excel, and Google Docs), calculates a new version number using an OpenAI n8n node, splits the text into optimal chunks, generates fresh embeddings, and inserts the data back into Supabase. This guarantees your RAG chatbot or application uses the latest available information, making this a crucial piece of the n8n automation pipeline for high-integrity AI services.

How it Works


  1. Trigger: The process begins with the Google Drive n8n trigger, specifically the "File Updated" event, watching a configured folder for any changes. This specialized n8n trigger ensures instant responsiveness.

  2. Preparation: The flow captures the file ID and MIME type using the Set File ID n8n node. A conditional If check may filter recent file creations before proceeding.

  3. Cleanup: The Delete Old Doc Rows Supabase n8n node removes all existing vector embeddings in the documents table associated with the updated file ID, ensuring clean data management.

  4. Version Control: An OpenAI n8n node (Set Version) is used after a Limit n8n node to automatically calculate and increment the document's version number (e.g., from v1 to v2).

  5. Data Retrieval and Routing: The flow attempts to download the file content. A key Switch n8n node routes the data based on the file type (PDF, Google Doc, Excel, or proprietary Word formats). Windows document files are converted into Google Docs format via an HTTP Request n8n node before processing.

  6. Extraction & Aggregation: Files are processed using the Extract from File n8n node for PDFs and text. Extracted Excel data is aggregated and concatenated using the Summarize n8n node.

  7. Chunking and Metadata: The text is fed into the LangChain Recursive Character Text Splitter to create optimal chunks. The Enhanced Default Data Loader n8n node attaches critical metadata, including the file ID, new version number, and timestamps, to each chunk.

  8. Embedding & Insert: The OpenAI Embeddings n8n node generates vector representations using the specified model. Finally, the Insert into Supabase Vectorstore n8n node inserts these high-quality, up-to-date document chunks into the designated Supabase vector table, completing this powerful n8n workflow.

Installation Guide


  1. Import: Copy the entire n8n workflow JSON provided and paste it into your n8n instance using the "Import Workflow" feature.

  2. Credentials: This n8n workflow requires three distinct credentials configurations:

Google Drive OAuth2 API: Used by the File Updated n8n trigger, Download File n8n node, and conversion nodes. Ensure read/write access to the monitored folder.
Supabase API: Required for the Delete Old Doc Rows and Insert into Supabase Vectorstore n8n node. This needs appropriate database access.
* OpenAI API: Required for the Set Version and Embeddings OpenAI n8n node for calculation and vector generation.

  1. Configuration: Update the File Updated n8n trigger to select the specific Google Drive folder you wish to monitor.

  2. Supabase Table: Verify that the Supabase table specified in the vector store n8n node (documents) is correctly configured and indexed for vector search.

  3. Activation: Once credentials and folder paths are set, activate the n8n workflow to begin automated synchronization.

Node Details

File Updated (Google Drive n8n trigger): The starting point. This n8n trigger monitors a specific folder for file modification events.
Set File ID (Set n8n node): A utility n8n node that extracts the crucial fileid and filetype from the incoming trigger data.
Delete Old Doc Rows (Supabase n8n node): Executes a database operation to delete previous versions of the document from the documents vector table using the file ID as a filter.
Set Version (OpenAI n8n node): Utilizes GPT-4o-mini to calculate the next sequential version number for robust document tracking metadata.
Switch (Switch n8n node): Manages flow control, routing the data path based on the document's MIME type to ensure the appropriate extraction method is selected (PDF, Excel, etc.).
Recursive Character Text Splitter (LangChain n8n node): An essential RAG component that breaks down large documents into smaller, manageable chunks (configured here at 2000 characters with 200 overlap).
Enhanced Default Data Loader (LangChain n8n node): Structures the resulting document chunks and applies rich, custom metadata gathered earlier in the n8n workflow.
Embeddings OpenAI (LangChain n8n node): Generates high-quality vector embeddings for the text chunks, necessary for efficient similarity search.


  • Insert into Supabase Vectorstore (LangChain n8n node): The final storage n8n node, inserting the chunked, vectorized documents and their metadata into the Supabase knowledge base table.

Related n8n Workflows

Free

Nodes: 18 Nodes
Updated: December 26 2025
View all
Created by
edisantosa
edisantosa

Featured*