AutomationFlowsAI & RAG › Telegram Bot with Google Gemini 2.5 Flash

Telegram Bot with Google Gemini 2.5 Flash

Original n8n title: Build a Text & Image Responding Telegram Bot with Google Gemini 2.5 Flash

ByAhmed Sherif @asherif08 on n8n.io

An intelligent Telegram bot powered by Google Gemini AI that provides smart responses to both text messages and images. Multi-Modal Input: Handles both text messages and image uploads AI-Powered Responses: Uses Google Gemini 2.5 Flash for intelligent reply generation Image…

Event trigger★★★★☆ complexityAI-powered15 nodesAgentMemory Buffer WindowGoogle Gemini ChatGoogle GeminiTelegram TriggerTelegram
AI & RAG Trigger: Event Nodes: 15 Complexity: ★★★★☆ AI nodes: yes Added:

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

This workflow follows the Agent → Googlegemini 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
{
  "id": "pl3YbOUdHMsDTYFE",
  "name": "TelegramBOT",
  "tags": [],
  "nodes": [
    {
      "id": "sticky-note-main",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1100,
        -300
      ],
      "parameters": {
        "color": 4,
        "width": 460,
        "height": 640,
        "content": "## \ud83d\udccb TELEGRAM AI BOT - SETUP GUIDE\n\n### \ud83c\udfaf What This Workflow Does:\nThis is an intelligent Telegram bot that can:\n- Answer text messages using AI\n- Analyze images sent by users\n- Maintain conversation context/memory\n- Provide formatted, attractive responses\n\n### \ud83d\udd27 Required Setup:\n\n**1. Telegram Bot Token:**\n   - Create a bot via @BotFather on Telegram\n   - Get your bot token\n   - Add credentials in n8n (Telegram account)\n\n**2. Google Gemini API Key:**\n   - Go to Google AI Studio (ai.google.dev)\n   - Create API key\n   - Add credentials in n8n (Google Gemini API account)\n\n**3. Webhook Configuration:**\n   - Activate the workflow\n   - The webhook URL will be automatically set\n\n### \ud83d\udcca Workflow Flow:\n1. **Telegram Trigger** receives messages\n2. **Route Types** checks if message is text or image\n3. For text: Direct to AI agent\n4. For images: Download \u2192 Analyze \u2192 Send to AI agent\n5. **AI Agent** processes with memory context\n6. Response sent back to user\n\n### \u26a0\ufe0f Important Notes:\n- Memory is per message ID (20 message context)\n- Image analysis uses Gemini 2.5 Flash\n- Responses are formatted for Telegram readability"
      },
      "typeVersion": 1
    },
    {
      "id": "sticky-note-trigger",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -820,
        -80
      ],
      "parameters": {
        "color": 5,
        "width": 280,
        "height": 160,
        "content": "## \ud83d\ude80 TRIGGER\nStarts when user sends a message to your Telegram bot.\n\nCaptures both text messages and images."
      },
      "typeVersion": 1
    },
    {
      "id": "sticky-note-router",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -600,
        -80
      ],
      "parameters": {
        "color": 6,
        "width": 260,
        "height": 140,
        "content": "## \ud83d\udd00 ROUTING\nChecks message type:\n- TEXT: Route to text mapper\n- IMAGE: Route to image handler"
      },
      "typeVersion": 1
    },
    {
      "id": "sticky-note-image",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -380,
        160
      ],
      "parameters": {
        "color": 3,
        "width": 360,
        "height": 380,
        "content": "## \ud83d\uddbc\ufe0f IMAGE PROCESSING\n1. Download image from Telegram\n2. Analyze with Gemini Vision\n3. Combine description + caption"
      },
      "typeVersion": 1
    },
    {
      "id": "sticky-note-agent",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        280,
        -80
      ],
      "parameters": {
        "color": 2,
        "width": 300,
        "height": 180,
        "content": "## \ud83e\udd16 AI AGENT\nGoogle Gemini processes the request with:\n- Conversation memory (20 messages)\n- Context-aware responses\n- Telegram-friendly formatting"
      },
      "typeVersion": 1
    },
    {
      "id": "568a5011-79b3-4660-88d9-c8b4c7c4519d",
      "name": "Knowledge Base Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        352,
        64
      ],
      "parameters": {
        "text": "=Use these Descriptions to reply with a message to the user according to his question simply, shortly, and make sure he understand the thing he attaches:\n\n\"\" {{ $json.text }} \"\"\n\n\nI need your output message to be well spaced and formatted and look as attractive as possible for a telegram response!",
        "options": {
          "systemMessage": ""
        },
        "promptType": "define"
      },
      "typeVersion": 1.9
    },
    {
      "id": "0c3f40bf-3773-4f7b-8b88-404e872d1188",
      "name": "Simple Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        400,
        464
      ],
      "parameters": {
        "sessionKey": "=memory_{{ $('Telegram Trigger').item.json.message.message_id }}",
        "sessionIdType": "customKey",
        "contextWindowLength": 20
      },
      "typeVersion": 1.3
    },
    {
      "id": "74a1218b-fb53-450c-8462-ccad268ad7ee",
      "name": "Map image prompt",
      "type": "n8n-nodes-base.set",
      "position": [
        128,
        272
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "48af2dcc-4ce9-45fc-abfc-54f803930092",
              "name": "text",
              "type": "string",
              "value": "=User image description:\n\n{{ $json.content.parts[0].text }}\n\nUser image caption: {{ $('Telegram Trigger').item.json.message.caption }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "85b4e665-2468-40c1-aa99-bd67e048d9fb",
      "name": "Map text prompt",
      "type": "n8n-nodes-base.set",
      "position": [
        -96,
        -208
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "38aec976-a32c-4b0e-85f4-c90adc16abc9",
              "name": "text",
              "type": "string",
              "value": "={{ $json.messages[0].text.body }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "482edd25-6a05-45cd-bb1f-c11d451938f5",
      "name": "Route Types",
      "type": "n8n-nodes-base.switch",
      "position": [
        -544,
        64
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Text",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "2fc5c912-629b-4cbe-b5e3-7e3f0651c628",
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.message.text }}",
                    "rightValue": "text"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Image",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "840b95b8-6559-4fb7-b32c-651451d6d0d2",
                    "operator": {
                      "type": "object",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.message.photo[2] }}",
                    "rightValue": "image"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "5cf1706c-cd33-4def-a99d-958d51654088",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        240,
        464
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "46fd3fa6-5261-4fcf-b148-52a7ce0b2c43",
      "name": "Analyze image",
      "type": "@n8n/n8n-nodes-langchain.googleGemini",
      "position": [
        -96,
        272
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "models/gemini-2.5-flash",
          "cachedResultName": "models/gemini-2.5-flash"
        },
        "options": {},
        "resource": "image",
        "inputType": "binary",
        "operation": "analyze"
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "5b5f176c-7d2d-4db2-9f55-cc4dc18f6d4a",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -768,
        64
      ],
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "typeVersion": 1.2,
      "alwaysOutputData": false
    },
    {
      "id": "6489c29a-2c59-4362-916a-605f3e63c866",
      "name": "Get a file",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -320,
        272
      ],
      "parameters": {
        "fileId": "={{ $json.message.photo[2].file_id }}",
        "resource": "file",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "7b1b528f-4e3e-48d3-bc33-638fa4a3f446",
      "name": "Send a text message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        704,
        64
      ],
      "parameters": {
        "text": "={{ $json.output }}",
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "332b36b7-0523-4d91-9ec6-0cb0b948d7f2",
  "connections": {
    "Get a file": {
      "main": [
        [
          {
            "node": "Analyze image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route Types": {
      "main": [
        [
          {
            "node": "Map text prompt",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get a file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analyze image": {
      "main": [
        [
          {
            "node": "Map image prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "Knowledge Base Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Map text prompt": {
      "main": [
        [
          {
            "node": "Knowledge Base Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Map image prompt": {
      "main": [
        [
          {
            "node": "Knowledge Base Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Route Types",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Knowledge Base Agent": {
      "main": [
        [
          {
            "node": "Send a text message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Knowledge Base Agent",
            "type": "ai_languageModel",
            "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

An intelligent Telegram bot powered by Google Gemini AI that provides smart responses to both text messages and images. Multi-Modal Input: Handles both text messages and image uploads AI-Powered Responses: Uses Google Gemini 2.5 Flash for intelligent reply generation Image…

Source: https://n8n.io/workflows/9265/ — 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

Telegram Trigger receives incoming messages (text, voice, photo, document). Switch routes by message type to appropriate processors: Text → forwarded as-is. Voice → downloaded and sent to Transcribe a

Memory Buffer Window, Telegram Trigger, Telegram +12
AI & RAG

Transform your Telegram messenger into a powerful, multi-modal personal or team assistant. This n8n workflow creates an intelligent agent that can understand text, voice, images, and documents, and ta

Memory Buffer Window, Telegram Trigger, Telegram +10
AI & RAG

A comprehensive n8n workflow demonstrating advanced AI agent orchestration, stateful conversation management, and multi-modal input processing for nutrition tracking applications.

Telegram, Memory Buffer Window, Google Gemini Chat +6
AI & RAG

&gt; AI-powered nutrition assistant for Telegram — log meals, set goals, and get personalized daily reports with Google Sheets integration.

Telegram, Google Gemini, Google Gemini Chat +7
AI & RAG

Rizz AI is not just a chatbot; it's a full-featured, AI-powered CRM for your dating life.

Telegram, Google Gemini, Google Gemini Chat +5