Telegram AI Image Editor via OpenRouter - n8n Workflow

Use this custom n8n workflow to automate AI image processing directly from Telegram. Send a photo, trigger the Nano Banana AI model (Gemini 2.5 Flash) via OpenRouter, and get the processed image back instantly. A perfect example of advanced n8n automation.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Users looking for advanced examples of Telegram automation.
Developers needing to integrate LLM vision capabilities into messaging platforms using an n8n node.
Anyone interested in leveraging specific AI models (like Nano Banana/Gemini 2.5 Flash) through OpenRouter within an n8n workflow framework.
Automation specialists seeking reusable n8n templates for binary data manipulation.

Overview

This powerful n8n workflow serves as an instant AI image processor, bridging the gap between mobile messaging and sophisticated multi-modal AI models. When a user sends a photo via Telegram, this automation instantly downloads the image, converts it into the necessary data URL format, sends it to the Nano Banana AI (Gemini 2.5 Flash via OpenRouter) for analysis or editing, and then converts the resulting Base64 output back into a photo, delivering the finished product back to the user.

This setup demonstrates complex data handling within n8n, moving seamlessly between binary data, Base64 strings, and JSON APIs. If you are looking for advanced n8n templates that showcase external API interaction combined with data transformation, this is an excellent reference point.

How it Works

This automation initiates with a specific n8n trigger and executes a comprehensive data transformation pipeline:


  1. Telegram Trigger: The n8n workflow starts when the 'Photo Message Receiver' n8n trigger detects an incoming Telegram message containing a photo.

  2. File Download: The 'Download Telegram Photo' n8n node uses the file ID extracted from the initial message to fetch the actual binary image data from Telegram's servers.

  3. Base64 Conversion: The 'Convert Photo to Base64' n8n node transforms the binary image data into a Base64 encoded string, preparing it for inclusion in the JSON API payload.

  4. Data URL Formatting: The 'Format Image Data URL' n8n node (a Code node) constructs the necessary data:image/png;base64,... URL structure required by the AI vision API.

  5. AI Processing: The 'Nano Banana Image Processor' n8n node sends an HTTP Request to OpenRouter, passing the formatted image data URL and the user's caption (if available) to the Gemini 2.5 Flash model for processing.

  6. Response Parsing: The 'Parse AI Response Data' n8n node meticulously extracts the Base64 string of the newly processed image from the complex JSON response structure provided by OpenRouter.

  7. Binary Reconversion: The 'Base64 to Binary File' n8n node reverses the encoding, turning the processed image Base64 string back into a standard binary file usable by Telegram.

  8. Final Delivery: The 'Send Processed Photo' n8n node completes the n8n workflow by sending the resulting image file back to the original Telegram chat ID.

Installation Guide

To deploy this powerful n8n workflow, follow these steps:


  1. Import the n8n Workflow: Copy the provided JSON data and paste it directly into your n8n instance via the 'New' > 'Import from JSON' option.

  2. Telegram Credentials: Set up your Telegram Bot API Token credential. Configure the 'Photo Message Receiver' n8n trigger by linking this credential and ensuring the bot is connected to your chat.

  3. OpenRouter Credentials: Create an OpenRouter API Key and configure a new 'OpenRouter API' credential within n8n. This must be linked to the 'Nano Banana Image Processor' HTTP Request n8n node.

  4. Chat ID Configuration: In the final 'Send Processed Photo' n8n node, replace YOURCHATID_HERE with the correct numerical ID where you want the processed photo to be sent. If you want the reply to go to the initiating user, use an expression to pull the chat.id from the triggering message.

  5. Activation: Save the n8n workflow and ensure the 'Photo Message Receiver' n8n trigger is correctly listening for messages. Activate the workflow to start processing images.

Node Details

Photo Message Receiver (Telegram Trigger n8n trigger):
Function: Starts the n8n workflow upon receiving a message containing a photo in Telegram.
Key Configuration: Updates set to message.
Download Telegram Photo (Telegram n8n node):
Function: Fetches the actual image file based on the file ID provided by the Telegram trigger.
Key Configuration: Uses expression ={{ $('Photo Message Receiver').item.json.message.photo[0].file_id }}.
Convert Photo to Base64 (Extract From File n8n node):
Function: Converts the downloaded binary data into a Base64 string property for API submission.
Key Configuration: Operation set to binaryToPropery.
Format Image Data URL (Code n8n node):
Function: Custom JavaScript code that prepends the necessary data:image/png;base64, prefix to the Base64 string.
Nano Banana Image Processor (HTTP Request n8n node):
Function: Sends the image data and caption to the OpenRouter API using the google/gemini-2.5-flash-image-preview:free model for AI processing.
Key Configuration: Authentication uses an OpenRouter API Key credential. The payload contains both text and the image URL expression.
Parse AI Response Data (Set n8n node):
Function: Extracts the resulting Base64 image string from the nested AI response JSON.
Key Configuration: Extracts data using a complex path and split function to isolate the Base64 string.
Base64 to Binary File (Convert To File n8n node):
Function: Converts the processed image Base64 string back into a binary file object.
Key Configuration: Operation set to toBinary.
Send Processed Photo (Telegram n8n node):
Function: Sends the final, AI-processed photo back to the user.
* Key Configuration: Operation set to sendPhoto, binaryData is checked.

Related n8n Workflows

Free

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

I love building smart n8n automations that actually work reliably. My focus is on making everyday tasks like email, social media, and CRM workflows simpler using AI. I've shared templates in the n8n community, including a WhatsApp Expense Tracker that people really enjoy. What keeps me excited is constantly trying new things - testing fresh nodes, playing with AI tools like LangChain, and discovering creative ways to connect systems!

Featured*