Telegram Chatbot with Gemini AI and Google Docs Knowledge Base - n8n Workflow

Build a powerful, responsive Telegram chatbot using this complete n8n workflow. Integrate Google Gemini Pro for intelligent replies and use Google Docs as a dynamic knowledge source. Download these n8n templates to automate customer support or personal assistant functions.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Automation Developers: Seeking robust n8n workflow examples integrating advanced AI and cloud services.
Community Managers: Needing an automated support or FAQ bot for their Telegram channels.
Entrepreneurs: Looking to deploy a low-cost, intelligent virtual assistant on Telegram.
AI Enthusiasts: Interested in using Google Gemini and other LLMs within an n8n node structure.

Overview

Developing a conversational AI agent often requires complex API management and flow control. This specific n8n workflow simplifies the process, providing a ready-to-use solution for linking a Telegram bot directly to Google Gemini Pro. The major value of this n8n templates solution is its inclusion of 'tools'—specifically, the ability for the AI to dynamically query a Google Docs document for contextual information or execute external HTTP requests. This transforms a simple Q&A bot into a comprehensive, context-aware assistant. Using this n8n automation, you can ensure timely, intelligent responses while utilizing flow control nodes like Wait to prevent rate-limiting issues and maintain professional pacing.

How it Works

The n8n workflow is activated instantly via the specialized n8n trigger for Telegram.


  1. Trigger Activation: The process begins when the Telegram Trigger n8n node receives a new message from a user in the configured chat.

  2. Item Handling: The flow immediately passes the data through the Loop Over Items n8n node, which ensures that even if multiple messages are received rapidly, they are processed sequentially or in batches, ensuring stability.

  3. AI Processing with Tools: The message then reaches the primary AI step: the Message a model (Google Gemini) n8n node. This powerful n8n node uses the Gemini 2.5 Pro model. Crucially, this node has 'tools' connected, including the Get a document in Google Docs n8n node and the HTTP Request n8n node. The Gemini model can decide, based on the user's query, whether to fetch data from the Google Doc or execute an external API call before generating its final answer.

  4. Response Generation: Gemini processes the input (and any retrieved tool data) and generates a friendly, conversational reply.

  5. Sending the Reply: The Send a text message n8n node takes the AI-generated text and sends it back to the original user's chat ID extracted from the initial Telegram n8n trigger data.

  6. Pacing Control: Finally, the Wait 1s n8n node introduces a short delay. This crucial step in the n8n workflow helps avoid hitting Telegram rate limits, especially when processing message batches, ensuring a smoother user experience.

Installation Guide

To deploy this comprehensive n8n workflow, follow these steps:


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

  2. Set up Telegram Credentials: Configure the Telegram Trigger and Send a text message n8n node with your Telegram Bot API Token. You will need to obtain the webhook URL provided by the n8n trigger and set it on your Telegram bot.

  3. Configure Google Credentials: Set up the required OAuth2 credentials for the Google Docs service in n8n. Ensure the service account has read access to the Google Doc specified in the Get a document in Google Docs n8n node.

  4. Configure Gemini API: Add your Google Gemini (PaLM) API Key credential to n8n, which will be used by the Message a model n8n node.

  5. Update Tool Parameters: Review the specific Google Docs URL in the Get a document in Google Docs n8n node and the URL in the HTTP Request n8n node to match your required knowledge base and external API endpoints.

  6. Activate: Save the n8n workflow and set the Telegram Trigger n8n node to 'Active' to start listening for incoming messages.

Node Details

This n8n workflow utilizes several specialized n8n node types to achieve its goal:

Telegram Trigger (n8n trigger):
Function: This is the starting n8n node, listening for new 'message' updates from the configured Telegram bot. It initiates the entire n8n automation.
Key Configuration: Updates parameter is set to message.

Loop Over Items1 (n8n node):
Function: Used for robust flow control, ensuring that every incoming message is processed individually or in controlled batches before proceeding to the AI logic.

Message a model (Google Gemini Pro n8n node):
Function: The central intelligence n8n node. It sends the Telegram user's prompt to the Gemini 2.5 Pro model for processing and response generation. It integrates 'tool' nodes for enhanced capability.
Key Configuration: Uses model models/gemini-2.5-pro.

Get a document in Google Docs (n8n node Tool):
Function: Configured as a tool accessible by the Gemini model, allowing the AI to fetch and use content from a specified Google Docs URL (a dynamic knowledge base).

HTTP Request (n8n node Tool):
Function: Another tool for the Gemini n8n node, enabling the AI to make external web calls (e.g., fetching real-time data or checking stock).
Key Configuration: Placeholder URL: https://devcodejourney.com/.

Send a text message (n8n node):
Function: Responsible for delivering the final AI response back to the Telegram user. It uses an expression to dynamically target the sender's chat ID.
Key Configuration: text is set to ={{ $json.content.parts[0].text }}.

Wait 1s (n8n node):
Function: Implements necessary pacing control by pausing the n8n workflow for one second between replies, which is essential when deploying high-volume n8n templates like chatbots.

Related n8n Workflows

Free

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

I build intelligent systems that automate tasks, streamline workflows, and enhance user experiences using tools like n8n, AI chatbots, and modern automation platforms. With a passion for solving real-world problems through smart technology, I create custom solutions that help individuals and businesses save time, scale faster, and work smarter. Whether it's integrating APIs, building no-code/low-code automations, or developing conversational AI, I'm always exploring the edge of what's possible.

Featured*