Knowledge Retrieval Chatbot using OpenAI Assistants - n8n Workflow

Use this comprehensive n8n workflow to deploy a high-fidelity RAG chatbot. It connects Google Drive files directly to the OpenAI Assistants API, serving responses via an interactive n8n trigger.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Technical teams building interactive Q&A bots based on proprietary documents.

  • Businesses needing an automated customer support solution derived from internal knowledge bases.

  • Developers exploring the advanced capabilities of the OpenAI Assistants API within an n8n workflow environment.

  • Users looking for practical n8n templates integrating cloud storage and AI retrieval systems.

Overview

Developing conversational AI that provides accurate, context-specific answers requires Retrieval-Augmented Generation (RAG). This powerful n8n workflow streamlines the entire process, allowing you to turn unstructured documents (like a Google Doc on a Music Festival) into an intelligent, queryable knowledge base using the OpenAI Assistants API.

This specific n8n workflow handles document retrieval, secure upload to OpenAI, setup of the Assistant with strict instructions (ensuring adherence to the source document), and deployment through a chat-based n8n trigger. This structure ensures that your chatbot provides highly relevant and accurate information, making it one of the most effective n8n templates for knowledge retrieval use cases. The included sticky notes offer guidance on expanding this core logic to platforms like WhatsApp or Telegram.

How it Works

This n8n workflow operates in two phases: Setup and Execution.

Phase 1: Setup (File Upload and Assistant Creation)


  1. Document Retrieval: The workflow starts by fetching a specified document (e.g., a 'Music Festival' guide) from Google Drive. Crucially, the n8n node converts the document from its native format into a PDF during the download operation.

  2. OpenAI File Upload: The converted PDF is then securely passed to the 'Upload File to OpenAI' n8n node, designating its purpose as 'assistants'.

  3. Assistant Creation: The 'Create new Assistant' n8n node utilizes the uploaded file ID. It configures the Assistant using the gpt-4-turbo-preview model, enables Knowledge Retrieval, and applies a comprehensive system prompt ('instructions'). These instructions rigorously enforce that the Assistant uses only the attached document for answers, ensuring high retrieval fidelity.

Phase 2: Execution (Chat Interaction)


  1. Chat Trigger Activation: The core interactive component is the 'Chat Trigger' n8n trigger. This acts as a webhook listener, waiting for incoming chat messages from an external source (like a custom web interface or integrated messaging app).

  2. Assistant Response: Upon receiving a message, the subsequent 'OpenAI Assistant' n8n node uses the pre-configured Assistant ID and the input message to generate a response. Because the Assistant was set up with Knowledge Retrieval and specific instructions, the answer is grounded in the source document defined earlier in the n8n workflow.

  3. Result Output: The Assistant's factual, relevant reply is returned back through the n8n trigger to the user.

Installation Guide

To deploy this powerful n8n workflow, follow these steps:


  1. Import the JSON: Copy the provided n8n workflow JSON and paste it into your n8n instance's workspace.

  2. Credential Setup:

- Google Drive: Configure the 'Get File' n8n node with your Google Drive OAuth2 API credentials. Ensure the account has access to the specified File ID.
- OpenAI: Set up your OpenAI API credentials (API Key) for both 'Upload File to OpenAI' and the 'Create new Assistant' n8n nodes. This is essential for the AI operations.

  1. Document Replacement: In the 'Get File' n8n node, update the File ID parameter to point to the document you wish the Assistant to learn from.

  2. Initial Setup Run: Before enabling the chat functionality, manually run the flow up to the 'Create new Assistant' n8n node. This completes Phase 1 (file upload and assistant creation).

  3. Activate the Chat Trigger: Enable the 'Chat Trigger' n8n node and note its webhook URL. This URL is your new knowledge retrieval endpoint.

  4. Testing: Send a test query to the webhook URL to confirm the OpenAI Assistant n8n node returns document-grounded responses.

Node Details

When clicking "Test workflow" (Manual Trigger): Used solely for manual testing of the initial setup phase (file upload and assistant creation). Although disabled, this standard n8n trigger is useful for first-time runs.
Get File (Google Drive n8n node): Downloads the source document. Key configuration includes using a specific File ID and enabling conversion to PDF format via the Google File Conversion option.
Upload File to OpenAI (OpenAI n8n node): Manages the file transfer to OpenAI's server storage, setting the file purpose to assistants for RAG capabilities.
Create new Assistant (OpenAI n8n node): The core configuration step. It sets the Assistant name, uses gpt-4-turbo-preview, enables knowledgeRetrieval, and inputs strict instructions to limit the Assistant's responses only to the uploaded document data.
Chat Trigger (@n8n/n8n-nodes-langchain.chatTrigger): This critical n8n trigger serves as the interactive entry point for the workflow, listening for external chat inputs via a webhook.
OpenAI Assistant (OpenAI n8n node): Executes the chat conversation using the established Assistant ID. It takes the input from the 'Chat Trigger' and routes it through the pre-configured RAG model, delivering a document-based answer. This is the final step in the live n8n workflow execution.

Related n8n Workflows

Free

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

Let's connect!

Featured*