🔓 Unlock all 10,000+ workflows & prompts free Join Newsletter →
✅ Full access unlocked — explore all 10,000 AI workflow and prompt templates Browse Templates →
Home n8n Workflow
January 22, 2026

Telegram + Google Gemini: instant replies for DMs

Lisa Granqvist Partner Workflow Automation Expert

Your Telegram DMs don’t slow down just because you’re busy. You answer the same questions, hunt for old context, and still manage to miss messages when things get hectic.

This Telegram Gemini replies setup hits support leads hardest, but marketers running campaigns and founders handling inbound feel it too. The goal is simple: fast answers that stay consistent, even when the message is an image.

You’ll see exactly how this n8n workflow routes DMs, keeps short-term memory across a conversation, and replies instantly with Google Gemini.

How This Automation Works

Here’s the complete workflow you’ll be setting up:

n8n Workflow Template: Telegram + Google Gemini: instant replies for DMs

Why This Matters: Slow, Inconsistent DM Replies

DMs look harmless until you’re drowning in them. One person asks for pricing, another sends a screenshot of an error, and someone else replies to a message you barely remember sending. If you answer manually, you either go too slow (and lose the lead) or you answer too fast (and get it wrong). The worst part is the context switching: you stop real work, dig for history, write a careful reply, then do it again 10 minutes later.

It adds up fast. Here’s where it breaks down in real teams.

  • Reply quality varies by who’s online, which means customers get mixed signals about policies, pricing, or timelines.
  • Image messages are a time sink because someone has to open them, interpret them, and type a response from scratch.
  • You lose conversation context across back-and-forth messages, so people repeat themselves and get annoyed.
  • Important DMs get buried during launches, support spikes, or travel days when you can’t sit in Telegram all day.

What You’ll Build: An AI DM Responder With Memory (Text + Images)

This workflow turns your Telegram bot into a fast first responder for direct messages. A user sends a DM to your bot, and n8n immediately checks what kind of message it is. If it’s text, the workflow builds a clean prompt and passes it to an AI agent that can keep short-term context across the conversation. If it’s an image, the workflow retrieves the Telegram file, asks Gemini to inspect the image content, then composes a prompt that includes what the image shows. In both cases, the AI agent generates a Telegram-friendly reply and sends it back instantly, without you opening the chat.

The workflow starts with a Telegram trigger and routes messages by type. Gemini handles both chat replies and image understanding, while a memory buffer keeps the last 20 messages available so responses don’t feel “stateless.” Finally, n8n sends the formatted reply right back to the same DM thread.

What You’re Building

Expected Results

Say you get about 30 DMs a day, and around a third include an image (screenshots, receipts, error messages). Manually, even “quick” replies take maybe 5 minutes each once you read, check context, and respond, so that’s roughly 2 to 3 hours daily. With this workflow, you spend about 10 minutes setting guardrails and reviewing edge cases, while the bot handles the routine questions and image explanations automatically. Most teams get a couple hours back on day one.

Before You Start

  • n8n instance (try n8n Cloud free)
  • Self-hosting option if you prefer (Hostinger works well)
  • Telegram for receiving and sending DMs via a bot
  • Google Gemini API to generate replies and analyze images
  • Telegram Bot Token (get it from @BotFather)

Skill level: Beginner. You’ll connect accounts, paste API keys, and adjust a couple prompts.

Want someone to build this for you? Talk to an automation expert (free 15-minute consultation).

Step by Step

A Telegram DM triggers the workflow. The Telegram Trigger node fires as soon as your bot receives a new message, so replies can be near-instant.

The message gets routed by type. A Switch node checks if the incoming content is plain text or an image. That decision controls which prompt gets composed next, so Gemini receives the right context instead of a messy “one prompt fits all.”

Images are retrieved and inspected. If the DM includes an image, n8n fetches the Telegram file, then sends it to Gemini’s image understanding node to describe what’s in it (errors, UI elements, documents, whatever the user sent).

An AI agent writes the reply with memory. The workflow passes the final prompt to a context-aware agent backed by a memory buffer window, which keeps the last 20 messages available so the response stays coherent across a back-and-forth conversation.

The response is sent to the same chat. The Telegram send node dispatches a formatted reply that reads well in Telegram and doesn’t require you to copy-paste anything.

You can easily modify the prompts to match your tone, or route certain keywords to a human escalation path. See the full implementation guide below for customization options.

Step-by-Step Implementation Guide

Step 1: Configure the Telegram Trigger

Set up the workflow entry point so your bot receives Telegram messages.

  1. Add and open Telegram Incoming Trigger.
  2. Set Updates to message.
  3. Confirm the node is connected to Route Message Type as the next step.

Step 2: Route Message Types and Retrieve Images

Split the flow so text messages and image messages are handled appropriately.

  1. Open Route Message Type and verify the first rule checks Left Value ={{ $json.message.text }} with the string exists operator.
  2. Verify the second rule checks Left Value ={{ $json.message.photo[2] }} with the object exists operator.
  3. Confirm the output labeled Text goes to Compose Text Prompt, and the output labeled Image goes to Retrieve Telegram File.
  4. In Retrieve Telegram File, set Resource to file and File ID to ={{ $json.message.photo[2].file_id }}.
  5. Credential Required: Connect your telegramApi credentials in Retrieve Telegram File.

If you expect larger images, confirm the index [2] exists in the incoming Telegram payload; otherwise, adjust the index to match your bot’s media sizes.

Step 3: Analyze Images and Compose Prompts

Prepare clean text for the AI by building prompt strings from user text or image analysis.

  1. Open Inspect Image Content and set Resource to image, Input Type to binary, and Operation to analyze.
  2. Set Model to models/gemini-2.5-flash.
  3. Credential Required: Connect your googlePalmApi credentials in Inspect Image Content.
  4. In Compose Image Prompt, add a string assignment named text with value =User image description: {{ $json.content.parts[0].text }} User image caption: {{ $('Telegram Incoming Trigger').item.json.message.caption }}.
  5. In Compose Text Prompt, add a string assignment named text with value ={{ $json.messages[0].text.body }}.

Step 4: Set Up the AI Agent and Memory

Configure the AI assistant to respond to either text or image prompts and maintain conversation context.

  1. Open Context Response Agent and set Text to =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: "" {{ $json.text }} "" I need your output message to be well spaced and formatted and look as attractive as possible for a telegram response!.
  2. Ensure Compose Text Prompt and Compose Image Prompt both connect to Context Response Agent.
  3. Open Session Memory Buffer and set Session Key to =memory_{{ $('Telegram Incoming Trigger').item.json.message.message_id }} with Context Window Length set to 20.
  4. Confirm Session Memory Buffer is linked to Context Response Agent via the ai_memory connection.
  5. Open Gemini Chat Engine and connect it to Context Response Agent as the ai_languageModel.
  6. Credential Required: Connect your googlePalmApi credentials in Gemini Chat Engine.

⚠️ Common Pitfall: The Session Memory Buffer is a sub-node; credentials are not added here. Ensure the language model credentials are configured in Gemini Chat Engine, which powers Context Response Agent.

Step 5: Configure the Telegram Reply Output

Send the AI-generated response back to the originating Telegram chat.

  1. Open Dispatch Telegram Reply and set Text to ={{ $json.output }}.
  2. Set Chat ID to ={{ $('Telegram Incoming Trigger').item.json.message.chat.id }}.
  3. Credential Required: Connect your telegramApi credentials in Dispatch Telegram Reply.

Step 6: Test and Activate Your Workflow

Validate the full path for both text and image messages, then enable the automation.

  1. Click Execute Workflow and send a text message to your Telegram bot to test the Route Message TypeCompose Text PromptContext Response Agent path.
  2. Send an image with a caption to test the Retrieve Telegram FileInspect Image ContentCompose Image PromptContext Response Agent path.
  3. Confirm a properly formatted response arrives via Dispatch Telegram Reply.
  4. Toggle the workflow to Active to run it continuously in production.
🔒

Unlock Full Step-by-Step Guide

Get the complete implementation guide + downloadable template

Troubleshooting Tips

  • Telegram credentials can fail if the bot token was regenerated. If replies suddenly stop, verify the token in @BotFather and update it in n8n’s Telegram credentials.
  • If image replies are blank, the file retrieval step is usually the culprit. Check the “Retrieve Telegram File” node output to confirm you’re actually downloading a file and not just receiving metadata.
  • Gemini API calls can error due to quota limits or missing permissions on the key. Open your Google AI API console, confirm billing/quota, then re-test the Gemini chat and image inspection nodes.

Quick Answers

What’s the setup time for this Telegram Gemini replies automation?

About 30 minutes if your bot token and Gemini key are ready.

Is coding required for this Telegram Gemini replies automation?

No. You’ll mostly connect accounts and tweak prompts to fit your use case.

Is n8n free to use for this Telegram Gemini replies workflow?

Yes. n8n has a free self-hosted option and a free trial on n8n Cloud. Cloud plans start at $20/month for higher volume. You’ll also need to factor in Google Gemini API usage costs, which depend on how many DMs and image analyses you run.

Where can I host n8n to run this automation?

Two options: n8n Cloud (managed, easiest setup) or self-hosting on a VPS. For self-hosting, Hostinger VPS is affordable and handles n8n well. Self-hosting gives you unlimited executions but requires basic server management.

Can I modify this Telegram Gemini replies workflow for different use cases?

Yes, and you should. Most customizations happen in the “Compose Text Prompt” and “Compose Image Prompt” steps, plus the “Context Response Agent” instructions that tell the bot how to behave. Common tweaks include adding your FAQs, setting boundaries (refund policy, availability, pricing rules), and routing certain keywords to a human instead of the bot.

Why is my Telegram connection failing in this workflow?

Usually it’s an invalid or replaced bot token. Regenerate or re-copy the token from @BotFather, update the Telegram credentials in n8n, then re-test the Telegram Trigger and the reply node. If it works in one node but not the other, confirm both nodes are using the same credential entry.

What volume can this Telegram Gemini replies workflow process?

If you self-host, there’s no execution cap (it mainly depends on your server and Gemini quota). On n8n Cloud, the limit depends on your plan’s monthly executions, and you can upgrade if the bot gets busy.

Is this Telegram Gemini replies automation better than using Zapier or Make?

Often, yes, because this isn’t a simple “message in, message out” zap. You’re routing between text and image flows, retrieving files, and keeping conversation context with a memory window, which is harder (and sometimes pricey) to do cleanly in Zapier. n8n also gives you more control over how prompts are constructed, which matters when you care about consistency. If you self-host, you’re not paying per task in the same way, so high DM volume is less scary. That said, if you only need a basic auto-reply with no memory and no image handling, Zapier or Make can be quicker to click together. Talk to an automation expert if you want help choosing.

Once this is running, your DMs stop being a constant interruption and start acting like an organized intake channel. The workflow handles the repetitive questions and the messy image explanations so you can focus on the conversations that actually need you.

Need Help Setting This Up?

Our automation experts can build and customize this workflow for your specific needs. Free 15-minute consultation—no commitment required.

Lisa Granqvist

Workflow Automation Expert

Expert in workflow automation and no-code tools.

×

Use template

Get instant access to this n8n workflow Json file

💬
Get a free quote today!
Get a free quote today!

Tell us what you need and we'll get back to you within one working day.

Get a free quote today!
Get a free quote today!

Tell us what you need and we'll get back to you within one working day.

Launch login modal Launch register modal