OpenAI Assistant RAG Setup with Google Drive Knowledge Base - n8n Workflow

Use this n8n workflow to seamlessly integrate OpenAI Assistants with documents stored in Google Drive. Automate RAG setup, file upload, and conversational memory.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

AI developers seeking scalable deployment of RAG agents.
Businesses needing to power customer service bots with internal documentation.
n8n users who want to leverage advanced OpenAI features like Assistants and file retrieval.
Anyone looking for robust n8n templates to handle complex multi-step AI provisioning.

Overview

This comprehensive n8n workflow addresses the challenge of keeping AI assistants updated with external, proprietary knowledge. It provides a two-part structure: a setup phase and a live interaction phase. The setup, initiated by a manual n8n trigger, handles the initial creation of the assistant, pulls the latest knowledge document (specified as a PDF from Google Drive), uploads it directly to the OpenAI platform, and updates the assistant to use that file. This guarantees that the assistant adheres to specific, accurate information defined by the user. Once configured, the live component uses an n8n trigger based on chat messages to activate the assistant, integrating a Window Buffer Memory n8n node to maintain conversational context.

How it Works

The n8n workflow operates in two distinct modes:

1. Setup and Provisioning (Manual Trigger)


  1. Start: The 'When clicking ‘Test workflow’' manual n8n trigger starts the process. This path is run only when setting up or updating the knowledge base.

  2. Assistant Creation: An OpenAI n8n node creates a new Assistant named 'Travel with us' with specific instructions (e.g., to use only the attached document and ignore irrelevant questions).

  3. Data Retrieval: The Google Drive n8n node downloads a specified file ID, configuring the download to convert the Google Document into a PDF binary property named data.pdf.

  4. Knowledge Upload: A subsequent OpenAI n8n node (resource: file) takes the downloaded binary file (data.pdf) and uploads it to the OpenAI server for RAG capabilities.

  5. Assistant Update: The final OpenAI n8n node in this chain updates the newly created assistant, linking the uploaded file ID, thus completing the knowledge provisioning step.

2. Live Interaction (Chat Trigger)


  1. Chat Activation: The 'When chat message received' n8n trigger waits for inbound messages (often exposed via a webchat interface).

  2. Context Management: A Window Buffer Memory n8n node is utilized to store and retrieve the immediate history of the conversation, ensuring the OpenAI Assistant maintains context.

  3. Response Generation: The 'OpenAI Assistent' n8n node executes the core logic, using the pre-configured Assistant ID and leveraging the file uploaded in the setup phase to generate grounded, relevant responses based on the Google Drive documentation. This robust use of the n8n node ensures a high quality output.

Installation Guide

To deploy this powerful n8n workflow template:


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

  2. Credentials Setup:

OpenAI: Set up your OpenAI credentials in n8n, ensuring they have access rights to create assistants and upload files.
Google Drive: Configure your Google Drive OAuth2 API credentials to allow the n8n workflow to read and download the specified document file ID.

  1. Configuration:

In the 'Google Drive' n8n node, update the fileId parameter to point to the specific Google Document or PDF file you wish to use as your knowledge base.
In the 'OpenAI1' and 'OpenAI Assistent' n8n nodes, ensure the assistantId matches the assistant created during the setup phase (or manually update them if you are modifying a pre-existing assistant).

  1. Run Setup: Execute the 'When clicking ‘Test workflow’' n8n trigger once to perform the setup, creating the Assistant and uploading the file. Note: Ensure 'failIfExists' is set correctly during testing.

  2. Activate: Save and activate the entire n8n workflow. The 'When chat message received' n8n trigger is now live for interaction.

Node Details

When clicking ‘Test workflow’ (Manual Trigger): This n8n trigger starts the configuration path. It is essential for initializing the OpenAI Assistant setup and data synchronization.
Google Drive n8n node: Functionally downloads a document using a specific fileId. Crucially, it converts the file to application/pdf and saves the output to a binary property called data.pdf for subsequent upload.
OpenAI (Create Assistant) n8n node: Creates the AI agent persona with detailed instructions on how to behave (e.g., friendly tone, strict adherence to the knowledge document).
OpenAI (File Upload) n8n node: Uploads the data.pdf binary property retrieved from the Google Drive n8n node to the OpenAI Files API, preparing it for RAG.
OpenAI (Update Assistant) n8n node: Attaches the file ID generated in the previous step to the specified Assistant ID, enabling knowledge retrieval.
When chat message received (Chat Trigger): This is the production n8n trigger, listening for user input to initiate a conversational exchange.
Window Buffer Memory n8n node: Manages the conversational state. It provides the memory component required for the OpenAI Assistant n8n node to recall previous turns in the chat.
OpenAI Assistent n8n node: Executes the live chat response logic, leveraging the integrated Assistant and its linked knowledge file to answer user queries accurately.

Related n8n Workflows

Free

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

Full-stack Web Developer based in Italy specialising in Marketing & AI-powered automations. For business enquiries, send me an email at [email protected] or add me on Linkedin.com/in/davideboizza

Featured*