AI Image Editor via Telegram Bot using Gemini - n8n Workflow

Create a robust AI image editing Telegram bot using this advanced n8n workflow. It uses the Gemini AI n8n node to process binary images based on text prompts (captions). Explore other n8n templates.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Creators and Designers: Those needing instant, AI-driven photo manipulation without specialized software.
Community Managers: Individuals running interactive Telegram bots that require visual content processing.
Automation Enthusiasts: Users looking to build sophisticated, multi-step n8n templates utilizing AI services and messenger platforms.
Developers: Anyone interested in deploying custom, serverless functions using the Google Gemini n8n node.

Overview

This powerful n8n workflow transforms a standard Telegram bot into a sophisticated AI image editor. The core problem it solves is bridging the gap between conversational messaging and high-compute image generation/editing tasks. Instead of manual uploads to an AI service, users simply send an image as a document to the bot, using the caption as the detailed instruction (or prompt) for the edit.

This specific n8n workflow leverages the Telegram Trigger to instantly start the process, ensuring the user experience is seamless and immediate. The logic flow is critical, ensuring that only valid requests (images with captions) proceed, saving valuable AI credits. Utilizing the dedicated Gemini n8n node for image editing provides high-quality results directly back to the user's chat, making this one of the most practical n8n templates for generative AI in real-time scenarios.

How it Works

This automation begins with the Telegram Trigger n8n node, which constantly listens for new messages addressed to the configured Telegram bot.


  1. Trigger and Validation: When a message is received, the workflow activates. The next step, the Filter: Has Caption and File n8n node, is essential. It performs an AND logic check, ensuring that the incoming message contains both a caption (which serves as the AI prompt) and a document (fileid). Requests missing either component are halted.

  2. Image Retrieval: If the filters pass, the subsequent Telegram n8n node, Download Image, uses the extracted fileid to retrieve the image file from Telegram’s servers. The file is stored internally as binary data.

  3. AI Processing: The binary data and the caption (prompt) are passed to the Edit Image with AI n8n node, which uses the Google Gemini service. The Gemini n8n node applies the requested edits—such as changing colors, adding elements, or refining details—to the image.

  4. Final Delivery: Finally, the Send Edited Image Telegram n8n node takes the resulting edited binary file and sends it back to the original chat ID, completing the end-to-end n8n workflow execution. This powerful chain demonstrates efficient usage of multiple n8n node types.

Installation Guide

To deploy this comprehensive n8n workflow and create your own AI image editor, follow these steps:

1. Import the n8n Workflow


  1. Copy the entire n8n workflow JSON provided.

  2. In your n8n instance, navigate to 'Workflows' and click 'New'.

  3. Click the menu (three dots) and select 'Import from JSON'. Paste the data and save the n8n template.

2. Configure Telegram Credentials


  1. Obtain your Bot Token from @BotFather in Telegram.

  2. In n8n, navigate to 'Credentials' and create a new 'Telegram API' credential.

  3. Enter your token and save.

  4. Assign this credential to the Telegram Trigger n8n node, the Download Image n8n node, and the Send Edited Image n8n node.

3. Configure Google Gemini Credentials


  1. Generate an API Key from Google AI Studio.

  2. In n8n, create a new 'Google Gemini API' credential.

  3. Enter the key and save.

  4. Assign this credential to the Edit Image with AI n8n node.

4. Activate

After setting all credentials, activate the Telegram Trigger n8n node and the entire n8n workflow.

Node Details

This n8n workflow utilizes several critical nodes to achieve its goal:

Telegram Trigger (n8n trigger):
Function: Starts the n8n workflow when a message is sent to the configured bot.
Key Configuration: Set to listen specifically for message updates.

Filter: Has Caption and File (n8n node):
Function: A fundamental flow control n8n node ensuring the image editing process only runs if both the text prompt (caption) and the file are present.
Key Configuration: Uses an 'AND' combinator checking for existence of message.caption and message.document.fileid.

Download Image (Telegram n8n node):
Function: Retrieves the binary image file based on the file ID provided by the n8n trigger.
Key Configuration: Resource set to file; File ID parameter uses expression {{ $json.message.document.fileid }}.

Edit Image with AI (Google Gemini n8n node):
Function: The core AI processing step. It takes the binary image input and applies generative edits using the text prompt.
Key Configuration: Resource set to image; Operation set to edit. The prompt is dynamically pulled from the original Telegram caption using {{ $('Telegram Trigger').item.json.message.caption }}. Output is saved to the binary property data.

Send Edited Image (Telegram n8n node):
Function: Sends the final, edited image back to the user.
* Key Configuration: Operation set to sendPhoto; Chat ID is derived from the n8n trigger ({{ $('Telegram Trigger').item.json.message.chat.id }}); Binary Data is enabled to send the result from the previous Gemini n8n node.

Related n8n Workflows

Free

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

AI Automation Consultant | Helping Business Owners Implement AI Systems for Growth and Lead Gen

Featured*