Document Q&A Chatbot with Google Drive and Telegram (RAG System) - n8n Workflow

Build a powerful RAG system using this n8n workflow. Automatically index Google Drive files into a vector store and answer questions via Telegram using the GPT-4-mini n8n node.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Technical users looking for advanced n8n templates for knowledge management.
Businesses needing automated Q&A based on internal documentation stored in Google Drive.
Developers building custom Retrieval-Augmented Generation (RAG) systems using the n8n platform.
Anyone seeking to deploy a cost-effective, real-time AI agent using a structured n8n node layout.

Overview

This comprehensive n8n workflow addresses the challenge of making unstructured corporate data searchable and conversational. By combining a Google Drive n8n trigger for indexing and a Telegram n8n trigger for user interaction, it provides a seamless knowledge agent experience. When a new file is uploaded to Google Drive, the n8n workflow automatically processes it, generates embeddings, and inserts the data into an in-memory vector store. Crucially, the system utilizes an OpenAI agent configured with a powerful system prompt (GPT-4-mini specified in the n8n node setup) to retrieve and analyze the relevant data chunks, ensuring that answers provided via Telegram are accurate and grounded in the source documents. This complete n8n solution is an excellent demonstration of production-ready RAG architecture built entirely within n8n.

How it Works

This n8n workflow operates via two distinct, interconnected paths:

Path A: Document Indexing (The Google Drive n8n workflow trigger)


  1. File Upload: The File uploaded n8n trigger constantly monitors a specified Google Drive folder for new files.

  2. Download: When a file is detected, the Download file n8n node retrieves the binary data.

  3. Loading & Embedding: The file is passed through the Default Data Loader and then processed by the Embedding model n8n node (using OpenAI credentials) to convert text into vector representations.

  4. Vector Storage: The Insert documents n8n node stores these embeddings in an in-memory vector store keyed as vectorstorekey, preparing the knowledge base for retrieval.

Path B: AI Chatbot Interaction (The Telegram n8n workflow trigger)


  1. User Question: The Listen for incoming events Telegram n8n trigger starts the process when a user sends a message.

  2. AI Agent Activation: The message is passed to the core AI Agent n8n node. This agent orchestrates the entire Q&A process using the gpt-4.1-mini Model.

  3. Retrieval Tool: The agent uses the Retrieve documents n8n node as a tool. This tool searches the centralized vectorstorekey using similarity search (top K=10) powered by the same OpenAI Embedding model used during indexing.

  4. Response Generation: Based on the retrieved data, the AI agent, guided by a specialized system prompt, formulates a comprehensive and source-grounded answer.

  5. User Notification: Finally, the Telegram n8n node sends the agent's output back to the user in Markdown format. This robust n8n workflow ensures your AI agent always uses the latest indexed data.

Installation Guide

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


  1. Import the n8n workflow: Copy the provided JSON data and paste it into your n8n instance via the "New" menu -> "Import from JSON."

  2. Google Drive Setup:

Set up credentials for the Google Drive n8n node.
In the File uploaded n8n trigger, specify the Folder ID of the Google Drive location you wish to monitor for documents.

  1. OpenAI Setup:

Configure your OpenAI credentials in both the Embedding model n8n node and the Model n8n node. Ensure your API key supports the specified model, which is gpt-4.1-mini in this n8n template.

  1. Telegram Setup:

Configure your Telegram Bot credentials in the Listen for incoming events n8n trigger and the final Telegram n8n node.

  1. Initial Indexing: Upload a document (e.g., PDF, DOCX) to the specified Google Drive folder and manually execute the n8n workflow to ensure the document indexing path completes successfully via the Insert documents n8n node.

  2. Activate and Test: Activate the n8n workflow and test the Q&A functionality by sending a message to your Telegram bot.

Node Details

This n8n workflow utilizes several specialized Langchain and standard n8n nodes:

File uploaded (Google Drive Trigger): Acts as the indexing n8n trigger. It listens for fileCreated events within a specific Google Drive folder ID (Rag-Folder).
Download file (Google Drive n8n node): Downloads the binary data of the newly uploaded file based on the trigger output.
Embedding model (Langchain Embeddings OpenAI n8n node): Generates vector embeddings using OpenAI. This node is shared between the indexing and retrieval paths, a critical configuration for RAG consistency.
Insert documents (Langchain Vector Store In Memory n8n node): Stores the documents and their embeddings into the in-memory vector store identified by vectorstorekey.
Listen for incoming events (Telegram Trigger): The communication n8n trigger, listening for user messages to initiate the conversational AI.
Retrieve documents (Langchain Vector Store In Memory n8n node): Configured in retrieve-as-tool mode (Top K=10). This tool is used by the AI agent to search the vector store based on the user's question.
Model (Langchain Chat OpenAI n8n node): Specifies the Language Model (gpt-4.1-mini) used by the agent for synthesizing grounded answers.
Simple Memory (Langchain Memory Buffer Window n8n node): Provides conversational context by storing recent chat history, using the Telegram chat ID as the session key.


  • AI Agent (Langchain Agent n8n node): The core control unit of the n8n workflow. It uses a highly detailed system prompt to guide the retrieval and analysis process, ensuring accurate answers are provided using the knowledge base.

Related n8n Workflows

Paid

Nodes: 11 Nodes
Updated: December 26 2025
View all
Created by
DuyTran
DuyTran

Featured*