AutomationFlowsAI & RAG › Build a Telegram Chatbot with Gemini

Build a Telegram Chatbot with Gemini

ByDevCode Journey @devcodejourney on n8n.io

This workflow connects a Telegram bot to OpenAi/Google Gemini (PaLM API) so the bot can reply to users with AI-generated answers. Useful for FAQs, assistants, classroom helpers, or bots that fetch document content to answer questions.

Event trigger★★★★☆ complexityAI-powered12 nodesGoogle GeminiTelegramGoogle Docs ToolTelegram TriggerGoogle Gemini ToolHTTP Request ToolOpenAIMistral Ai Tool
AI & RAG Trigger: Event Nodes: 12 Complexity: ★★★★☆ AI nodes: yes Added:

This workflow corresponds to n8n.io template #8615 — we link there as the canonical source.

This workflow follows the Googlegemini → Telegram recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "nodes": [
    {
      "id": "edc0b0da-3e56-4b56-acd4-a4229ea6fc49",
      "name": "Message a model",
      "type": "@n8n/n8n-nodes-langchain.googleGemini",
      "position": [
        2144,
        -192
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "models/gemini-2.5-pro",
          "cachedResultName": "models/gemini-2.5-pro"
        },
        "options": {},
        "messages": {
          "values": [
            {
              "content": "Replay test write user-friendly."
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "d79df4cc-cfbe-4dbc-9476-e5aecd36d49d",
      "name": "Send a text message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2528,
        -192
      ],
      "parameters": {
        "text": "={{ $json.content.parts[0].text }}",
        "chatId": "={{ $('Telegram Trigger').item.json.message.from.id }}",
        "replyMarkup": "replyKeyboard",
        "additionalFields": {},
        "replyKeyboardOptions": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "c1722531-4561-4931-89ac-4523f72e3eda",
      "name": "Get a document in Google Docs",
      "type": "n8n-nodes-base.googleDocsTool",
      "position": [
        2496,
        64
      ],
      "parameters": {
        "simple": false,
        "operation": "get",
        "documentURL": "https://docs.google.com/document/d/19vaCViYaFkjFM6azAMf6fH6tDL2cwSsjTE5vX3eK6Ss"
      },
      "typeVersion": 2
    },
    {
      "id": "3af1e6d6-5e7a-42f7-a0b9-96de39d2ca82",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        1536,
        -208
      ],
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "d8521089-0cca-45bb-a35b-9ef9d59ff19c",
      "name": "Wait 1s",
      "type": "n8n-nodes-base.wait",
      "position": [
        2800,
        -192
      ],
      "parameters": {
        "amount": 1
      },
      "typeVersion": 1.1
    },
    {
      "id": "f263dd74-fe7a-49e5-9dd3-4fab35510f32",
      "name": "Message a model in Google Gemini",
      "type": "@n8n/n8n-nodes-langchain.googleGeminiTool",
      "position": [
        2304,
        64
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "models/gemini-2.0-flash-exp",
          "cachedResultName": "models/gemini-2.0-flash-exp"
        },
        "options": {},
        "messages": {
          "values": [
            {
              "content": "Replay test write user-friendly."
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "f80de8b8-2844-4827-b17e-0802546c4cea",
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        2080,
        64
      ],
      "parameters": {
        "url": "https://devcodejourney.com/",
        "options": {},
        "toolDescription": "Replay test write user-friendly."
      },
      "typeVersion": 4.2
    },
    {
      "id": "2dc68b6a-157e-48b1-a564-644b9ca96394",
      "name": "Loop Over Items1",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        1792,
        -208
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "96ae7f1c-42ec-4cee-b2f2-5d3b801783a4",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        160,
        -256
      ],
      "parameters": {
        "width": 1312,
        "height": 2448,
        "content": "# \ud83e\udd16 Telegram + Gemini + Google Docs Automation in n8n\n\n## \ud83d\udccc Overview\n\nThis n8n workflow listens for messages sent to a Telegram bot and replies with AI-generated responses using **Google Gemini (PaLM)**. It optionally interacts with **Google Docs** to fetch documents and makes external API requests using an **HTTP Request** node.\n\nThe flow also includes batching and waiting logic to control the pace of replies, making it scalable and human-friendly.\n\n---\n\n## \ud83e\udde0 What This Workflow Does\n\n### \u2705 1. Trigger from Telegram\n- **Node**: `Telegram Trigger`\n- **Function**: Starts the workflow when a message is received via your Telegram bot.\n\n### \u2705 2. Loop Through Messages\n- **Node**: `Loop Over Items`\n- **Function**: Allows processing multiple incoming messages if required, using batching logic.\n\n### \u2705 3. AI-Powered Reply with Gemini\n- **Node**: `Message a model` (Google Gemini Pro)\n- **Function**: Sends the message to the Gemini AI (via Google PaLM API) to generate a human-friendly, conversational response.\n\n### \u2705 4. Send AI Response via Telegram\n- **Node**: `Send a text message`\n- **Function**: Sends the generated Gemini response back to the user on Telegram.\n\n### \u2705 5. Delay Between Replies\n- **Node**: `Wait 1s`\n- **Function**: Adds a 1-second delay before proceeding to the next message in the loop (helps avoid Telegram rate limits and creates more natural pacing).\n\n### \u2705 6. Optional: External API Request\n- **Node**: `HTTP Request`\n- **Function**: Makes an external API request to `https://devcodejourney.com/` (placeholder URL).\n- **Note**: Currently not connected to message flow but can be used to fetch or send additional data.\n\n### \u2705 7. Optional: Fetch Document from Google Docs\n- **Node**: `Get a document in Google Docs`\n- **Function**: Retrieves the contents of a Google Docs document from a provided link. Can be used to add static text, FAQs, or templates to the conversation.\n\n### \u2705 8. Optional: Alternate Gemini Tool\n- **Node**: `Message a model in Google Gemini`\n- **Function**: Uses a different version (`gemini-2.0-flash-exp`) of the Gemini AI model for fast responses or testing purposes.\n\n---\n\n## \ud83d\udd27 Technologies Used\n\n- **Telegram Bot API** \u2013 for message triggers and replies  \n- **Google Gemini (PaLM API)** \u2013 for AI-generated responses  \n- **Google Docs API** \u2013 to fetch document content  \n- **HTTP Request** \u2013 to connect to any third-party API  \n- **n8n** \u2013 no-code/low-code workflow automation platform  \n\n---\n\n## \u2699\ufe0f Use Cases\n\n- AI Chatbot for Telegram using Gemini  \n- Personal Assistant or FAQ bot reading from Google Docs  \n- Customer service bot that replies in natural language  \n- Looping conversations with controlled pacing  \n- External data fetching with AI processing  \n\n---\n\n## \ud83d\udccc Notes\n\n- Make sure you have the correct credentials configured in n8n for:\n  - Telegram Bot\n  - Google Docs OAuth2\n  - Google Gemini API (PaLM)\n- You can add error-handling nodes or conditionals to expand the logic.\n- This can be extended into a full AI chatbot or customer support bot.\n\n---\n\n## \ud83e\udde9 Nodes Used\n\n| Node Name                          | Type                       | Purpose                                 |\n|-----------------------------------|----------------------------|-----------------------------------------|\n| Telegram Trigger                  | telegramTrigger            | Listens for incoming Telegram messages  |\n| Loop Over Items                   | splitInBatches             | Handles batching of incoming data       |\n| Message a model                   | langchain.googleGemini     | Sends prompt to Google Gemini (Pro)     |\n| Send a text message               | telegram                   | Sends response back to Telegram user    |\n| Wait 1s                           | wait                        | Adds a delay between responses          |\n| HTTP Request                      | httpRequestTool            | Sends HTTP request to external API      |\n| Get a document in Google Docs     | googleDocsTool             | Fetches content from Google Docs        |\n| Message a model in Google Gemini | googleGeminiTool           | Alternate Gemini model for responses    |\n\n---\n\n\n## \ud83d\ude4b For Help & Community\n- \ud83d\udc7e Discord: [n8n channel](https://discord.gg/9SDFKGnh2Y)\n- \ud83c\udf10 Website: [devcodejourney.com](https://devcodejourney.com)\n- \ud83d\udd17 LinkedIn: [Connect with Shakil](https://www.linkedin.com/in/shakilpg/)\n- \ud83d\udcf1 WhatsApp Channel: [Join Now](https://whatsapp.com/channel/0029Vb5l6JuDTkK5BRORNn0B)\n- \ud83d\udcac Direct Chat: [Message Now](https://wa.me/8801316320957)"
      },
      "typeVersion": 1
    },
    {
      "id": "7c5bddc4-3b0a-4d0f-a81f-ffa1c1fd062f",
      "name": "Message a model1",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        2144,
        -432
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "options": {},
        "messages": {
          "values": [
            {}
          ]
        }
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "76e37376-51cb-42c2-9aaf-29046ffc3110",
      "name": "Extract text in Mistral AI",
      "type": "n8n-nodes-base.mistralAiTool",
      "position": [
        2304,
        272
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "mistralCloudApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "8c25f18e-1c4e-4e2f-9bbf-eec37279dc79",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2144,
        -528
      ],
      "parameters": {
        "width": 224,
        "height": 432,
        "content": "## use one message model"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Wait 1s": {
      "main": [
        [
          {
            "node": "Loop Over Items1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "ai_tool": [
        [
          {
            "node": "Message a model",
            "type": "ai_tool",
            "index": 0
          },
          {
            "node": "Message a model1",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Message a model": {
      "main": [
        [
          {
            "node": "Send a text message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items1": {
      "main": [
        [],
        [
          {
            "node": "Message a model",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Loop Over Items1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send a text message": {
      "main": [
        [
          {
            "node": "Wait 1s",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract text in Mistral AI": {
      "ai_tool": [
        [
          {
            "node": "Message a model1",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Get a document in Google Docs": {
      "ai_tool": [
        [
          {
            "node": "Message a model",
            "type": "ai_tool",
            "index": 0
          },
          {
            "node": "Message a model1",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Message a model in Google Gemini": {
      "ai_tool": [
        [
          {
            "node": "Message a model",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

This workflow connects a Telegram bot to OpenAi/Google Gemini (PaLM API) so the bot can reply to users with AI-generated answers. Useful for FAQs, assistants, classroom helpers, or bots that fetch document content to answer questions.

Source: https://n8n.io/workflows/8615/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

Personal Assistant with Long-Term Memory (StudioMeyer). Uses stickyNote, telegramTrigger, n8n-nodes-studiomeyer-memory, telegram. Event-driven trigger; 26 nodes.

Telegram Trigger, N8N Nodes Studiomeyer Memory, Telegram +2
AI & RAG

The workflow starts by listening for messages from Telegram users. The message is then processed, and based on its content, different actions are taken. If it's a regular chat message, the workflow ge

Telegram Trigger, OpenAI, Telegram
AI & RAG

A lightweight, self-hosted AI assistant built entirely in n8n. Multi-channel messaging (Telegram, WhatsApp, Gmail), persistent memory, task management, and autonomous work — all in a single visual wor

Telegram Trigger, OpenRouter Chat, Data Table +20
AI & RAG

This workflow implements an advanced AI automation agent (OpenClaw Agent) that interacts with users through Telegram and integrates multiple AI models, external tools, and cloud services to automate c

Telegram Trigger, Telegram, OpenAI +21
AI & RAG

Your AI workforce is ready. Are you?

Google Sheets Tool, Mcp Trigger, Google Drive +29