Telegram Bot for Conversational AI and Image Analysis with Gemini - n8n Workflow

Build a versatile conversational AI Telegram bot using this advanced n8n workflow. Integrate Telegram with Google Gemini 2.5 Flash for intelligent text responses, image analysis, and full conversation memory using this robust n8n template.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Automation Engineers: Seeking ready-to-use n8n templates for complex AI integrations.
Community Managers: Needing an automated, intelligent response system for a Telegram channel.
Developers: Interested in implementing multi-modal AI (text and image) logic within an n8n environment.
Bot Builders: Users who need a complete, scalable n8n workflow solution for Telegram.

Overview

This comprehensive n8n workflow provides a powerful solution for deploying an intelligent Telegram bot capable of handling modern, multi-modal communication. Unlike simple bots, this sophisticated automation uses Google Gemini 2.5 Flash to process both standard text messages and user-uploaded images, offering rich visual analysis.

Key to the success of this n8n workflow is the integrated conversation memory, ensuring the bot remembers the context of the previous 20 messages, leading to highly relevant and natural dialogue. The entire automation is designed to be highly responsive, utilizing the n8n trigger for Telegram to instantly begin processing user requests, routing the message type, and delivering a well-formatted, context-aware reply through the final n8n node action. This robust n8n template dramatically reduces the complexity of building advanced conversational agents.

How it Works

This n8n workflow initiates immediately upon receiving a message via the Telegram platform.


  1. Trigger Reception: The n8n trigger, specifically the Telegram Trigger node, listens for incoming messages, whether they contain text or media.

  2. Message Routing: The Route Types switch n8n node analyzes the incoming JSON data to determine if the message contains plain text or an image (photo).

  3. Text Path: If text is detected, the Map text prompt Set n8n node formats the user's message for the AI agent.

  4. Image Path (Multi-Modal): If an image is detected, the workflow executes several steps:

The Get a file Telegram n8n node downloads the image using the provided file ID.
The Analyze image Google Gemini n8n node processes the binary file data, generating a detailed description of the image content.
* The Map image prompt Set n8n node combines the generated image description with the user's caption (if available) into a single, cohesive prompt.

  1. AI Processing: Both paths converge on the Knowledge Base Agent n8n node. This agent utilizes the powerful Google Gemini Chat Model and maintains context via the Simple Memory n8n node, which stores the last 20 messages tied to the conversation's ID. The prompt ensures the output is well-formatted for Telegram.

  2. Response: The final output from the AI agent is sent to the Send a text message Telegram n8n node, delivering the conversational response directly back to the user's chat ID.

Installation Guide

To deploy this powerful n8n workflow, follow these steps:


  1. Import: Copy the provided JSON data and paste it directly into your n8n instance to import this n8n template.

  2. Telegram Setup: Create a new bot using Telegram's @BotFather. Obtain the Bot Token. Configure a new Telegram API credential in n8n using this token.

  3. Google Gemini Setup: Obtain a Google Gemini API Key from Google AI Studio. Configure a new Google Gemini (PaLM) credential in n8n.

  4. Credential Assignment: Ensure that the Telegram Trigger, Get a file, and Send a text message nodes are linked to your Telegram credentials, and the Analyze image and Google Gemini Chat Model nodes are linked to your Google Gemini credentials.

  5. Activation: Once credentials are set, activate the n8n workflow. The Telegram Trigger n8n node will automatically configure its webhook URL with Telegram, making the bot live and ready to receive messages.

Node Details

Telegram Trigger (n8n trigger): The entry point of the n8n workflow, capturing all message updates from the connected Telegram bot.
Route Types (Switch n8n node): Determines the execution path based on whether the incoming message contains text or a valid image payload.
Get a file (Telegram n8n node): Downloads the image file from Telegram using the provided file ID, preparing it for AI analysis.
Analyze image (Google Gemini n8n node): Uses the Gemini 2.5 Flash model for multi-modal vision analysis, turning the binary image data into a descriptive text prompt.
Map image prompt / Map text prompt (Set n8n nodes): Standardize the input data structure for the AI agent, combining image descriptions and captions into a unified query.
Google Gemini Chat Model (LLM n8n node): Serves as the large language model backend for the agent, providing the intelligence for the conversational responses.
Simple Memory (AI Memory n8n node): Manages the conversational context, crucial for maintaining coherence across multiple interactions within this complex n8n workflow.
Knowledge Base Agent (Agent n8n node): The core logic engine that takes the user prompt, utilizes memory, and directs the LLM to generate the final, formatted reply.


  • Send a text message (Telegram n8n node): The final action n8n node, responsible for sending the fully processed, AI-generated response back to the user.

Related n8n Workflows

Free

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

Featured*