Google Drive to OpenAI Vector Store Synchronization - n8n Workflow

Use this robust n8n workflow to automatically synchronize documents from Google Drive into your OpenAI Assistant vector store. Keep your RAG knowledge base updated using this n8n template.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

AI Developers and ML Engineers who need to maintain up-to-date RAG knowledge bases.
Users relying on OpenAI Assistants who source their files from Google Drive.
Anyone seeking a powerful, scheduled synchronization solution built with an n8n workflow.
Automation enthusiasts looking for advanced n8n templates for complex file operations.

Overview

Maintaining consistency between source documents (like those stored in Google Drive) and external AI knowledge bases (like OpenAI Vector Stores) is critical for accurate Retrieval-Augmented Generation (RAG). Manually tracking changes, additions, and deletions is tedious and prone to error. This sophisticated n8n workflow solves this problem entirely. By using the Compare Datasets n8n node, the workflow intelligently determines which files are new, updated, or deleted, and executes the necessary API calls to the OpenAI platform. This n8n template ensures your AI knowledge base is perpetually accurate without any manual intervention, triggered reliably by an n8n trigger.

How it Works

This automation begins with a scheduled n8n trigger (Schedule trigger) or manual execution ("Test workflow" clicked).


  1. Data Retrieval: The n8n workflow simultaneously fetches a list of current files in the target Google Drive folder and a list of files already registered in the OpenAI Vector Store (using List vector store files [OpenAI]).

  2. Comparison and Classification: The core logic resides in the Compare Google Drive files with vector store files n8n node, which classifies items into four categories: files to Create (new), files to Update (modified), files to Delete (removed from GDrive), or files to Ignore (already synchronized).

  3. Actionable Merge: The actions (Create, Update, Delete) are merged and passed to the main loop (Loop over files).

  4. Conditional Processing: Inside the loop, a series of conditional n8n nodes determines the required action.

  5. Creation/Update Path: If a file needs creation or updating, the n8n workflow downloads the file from Google Drive, uses the dedicated OpenAI n8n node (Upload new or updated file) to stage the file, and then uses a subsequent httpRequest n8n node (Add uploaded file to vector store [OpenAI]) to link the uploaded file ID to the specific vector store.

  6. Deletion Path: If a file needs deletion, an httpRequest n8n node (Delete outdated file or previous version) removes the file reference from the OpenAI vector store, ensuring data cleanup.

  7. Finalization: The loop concludes, and the aggregated results signal the end of this comprehensive n8n workflow execution.

Installation Guide

To deploy this powerful n8n template, follow these steps:


  1. Import: Copy the provided JSON data and import it into your n8n instance using the 'New' menu -> 'Import from JSON'.

  2. Credentials: You must configure credentials for the following services:

Google Drive: Requires credentials with access to the target folder.
OpenAI: Requires API key credentials for the Upload new or updated file n8n node and permissions to manage Vector Stores via HTTP Requests.

  1. Configuration:

In the List files from folder Google Drive n8n node, specify the ID of the Google Drive folder you wish to synchronize.
In all OpenAI HTTP Request nodes (e.g., List vector store files [OpenAI]), ensure the necessary Vector Store ID is correctly configured in the URL and parameters.

  1. Activation: Once credentials are set, activate the n8n workflow. It will run based on the defined scheduleTrigger.

Node Details

Schedule trigger / Manual Trigger: The starting n8n trigger for the automation. Allows for periodic or manual execution of the n8n workflow.
Google Drive Node (List files from folder): Fetches metadata (like IDs and last modified times) for all files in the specified Google Drive folder.
HTTP Request Node (List vector store files [OpenAI]): Communicates with the OpenAI API to retrieve a list of existing file IDs and metadata within the designated vector store.
Compare Datasets Node: A crucial n8n node that compares the Google Drive list against the OpenAI list based on unique identifiers (likely file names or custom metadata) and modification timestamps, classifying the required action (Create, Update, Delete, Ignore).
Merge Node / Set Nodes: These n8n nodes handle the routing and preparation of data for the main processing loop.
Filter Node: Ensures only actionable files (non-ignored) proceed to the core loop in the n8n workflow.
Loop over files (Split In Batches Node): Iterates through each file that requires action (creation, update, or deletion).
Google Drive Node (Download new or updated file): Downloads the actual binary content of the file from Google Drive.
OpenAI Node (Upload new or updated file): This dedicated n8n node uploads the downloaded file to the OpenAI API file endpoint.
HTTP Request Node (Add uploaded file to vector store [OpenAI]): Links the uploaded OpenAI file ID to the target Vector Store ID using the OpenAI Assistant API endpoint.


  • HTTP Request Node (Delete outdated file or previous version): Handles the API call necessary to remove file references from the vector store for cleanup or deletion actions.

Related n8n Workflows

Paid

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

Automation consultant helping teams eliminate repetitive work. Successfully implemented n8n within an ISO27001-certified environment. Available for consulting on custom implementations, particularly around AI integrations.

Featured*