Automate Image Analysis & Response on Telegram with n8n

This workflow automates image analysis for Telegram messages using n8n and OpenAI. It identifies if an image is present, analyzes it, and sends insightful text responses back, saving time and improving interaction accuracy on Telegram.
telegramTrigger
telegram
openAi
+3
Workflow Identifier: 1841
NODES in Use: Telegram Trigger, Telegram, Sticky Note, Wait, OpenAI (Langchain), Switch

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

Visit through Desktop for Best experience

1. Opening Problem Statement

Meet Alex, a community manager for a busy Telegram group where members regularly share images for feedback, updates, and content review. Alex spends hours every day manually checking each image, trying to interpret what each picture contains, then typing out responses. This tedious back-and-forth wastes valuable time and sometimes leads to errors in understanding the image’s content, causing frustration among group members.

Imagine if every image sent in the group could automatically be analyzed and a helpful response generated instantly. How many hours could Alex save weekly? How much smoother could the conversations run without delays? This exact pain point inspired the creation of an automated workflow that listens for images in Telegram chats, analyzes them intelligently, and replies with meaningful feedback — all without manual effort.

2. What This Automation Does

This n8n workflow integrates Telegram and OpenAI’s image analysis to deliver smart responses. Here’s what happens when it runs:

  • Detects incoming images: Watches Telegram chats and triggers only when an image is sent.
  • Prevents errors by validation: Checks if the message contains an image and handles text or empty submissions gracefully.
  • Uses OpenAI to analyze images: Sends the image in base64 to OpenAI to extract meaningful insights.
  • Automates replies back to Telegram: Sends the analyzed content as text replies to the original chat.
  • Error messaging for non-image uploads: Prompts users to upload an image if none detected.
  • Manages workflow timing: Uses a wait step to ensure smooth message sending after invalid inputs.

By automating these steps, it saves Alex hours each week and ensures that every image is understood and responded to accurately and quickly.

3. Prerequisites ⚙️

  • 🔑 n8n account: The platform to create and run this workflow.
  • 📧 Telegram account: For receiving and sending messages and images.
  • 🔐 OpenAI account: To use AI-powered image analysis capabilities.
  • 🔌 Configurations: Properly set up Telegram and OpenAI credentials within n8n.

4. Step-by-Step Guide to Build This Workflow

Step 1: Set up Telegram Trigger to Get Incoming Images

Navigate to Nodes > Search for “Telegram Trigger”.

Configure the node as follows:

  • Updates: Select message to trigger on new Telegram messages.
  • Additional Fields: Enable Download to obtain the actual image file.
  • Credentials: Connect your Telegram API account.

You should see your webhook URL generated. Send an image to your Telegram account to test the trigger activates.

Common mistake: Forgetting to enable image download will prevent the workflow from accessing the photo content.

Step 2: Add a Switch Node to Verify if an Image Exists

Add a Switch node to evaluate whether the message contains a photo.

Configure the Switch with two rules:

  • Image: Check if {{$json.message.photo}} array exists.
  • Empty: Check if {{$json.message.photo}} does not exist.

This step ensures the workflow branches accordingly: processing images or handling missing images.

Common mistake: Using incorrect syntax in the condition or wrong field names can cause the switch not to work.

Step 3: Handle Non-Image Messages Gracefully

For the “Empty” branch, add a Wait node with a delay (e.g., 3 seconds) to pace the response.

Follow this with a Telegram node configured to send a message back, like “Please Upload an Image ….” to the user’s chat ID.

This guides users to send valid content, improving user interaction.

Step 4: Analyze the Image with OpenAI

In the “Image” branch, add the OpenAI (Langchain Image) node.

Configure it as:

  • Resource: Image
  • Operation: Analyze
  • Input Type: Base64 (the image from trigger is automatically downloaded and accessible)
  • Credentials: Use your OpenAI API credentials

This node sends the photo to OpenAI’s vision model and returns insightful descriptions or analysis.

Tip: Make sure the input is correctly base64 encoded. This node handles that when images are downloaded.

Step 5: Send the Analyzed Content Back via Telegram

Attach a Telegram message node to send the analysis results back to the chat.

Configure it to:

  • Chat ID: Use expression {{$node["Get the Image"].json.message.chat.id}} to target the original sender.
  • Text: Map to {{$json.content}} or the output property from the OpenAI node containing the analysis text.
  • Ensure Append Attribution is off for cleaner messages.

5. Customizations ✏️

  • Change the error message text: In the “Update Telegram Error Message” node, modify the text to suit your group’s tone or language.
  • Add image caption detection: Extend the Switch node to also check for caption and respond or log accordingly.
  • Multiple language support: Insert a Code node to detect language from captions or messages and modify the OpenAI prompt dynamically.
  • Log analysis to database: Add Google Sheets or any database node to save image analysis results for tracking.
  • Use another AI provider: Replace the OpenAI Analyze node with nodes for other AI services if preferred.

6. Troubleshooting 🔧

Problem: “No image found in the message.”

Cause: The Telegram message doesn’t contain a photo array or the node fails to detect it.

Solution: Double-check the Switch node condition to ensure it checks {{$json.message.photo}} existence and confirm the Telegram Trigger is configured to download images.

Problem: “OpenAI node returns error or empty response.”

Cause: Image data not sent in the correct base64 format or API limits reached.

Solution: Verify image download in the trigger, and check OpenAI credentials. Also, review your API usage and rate limits.

7. Pre-Production Checklist ✅

  • Ensure Telegram API credentials are valid and connected in n8n.
  • Test sending images to the Telegram bot/account to confirm trigger activation.
  • Check OpenAI API key validity and the workflow node is properly authorized.
  • Verify Switch node correctly differentiates messages with and without images.
  • Test fallback message is sent when a non-image is received.

8. Deployment Guide

Activate the workflow in n8n by toggling the workflow from draft to active mode.

Monitor workflow executions in the n8n dashboard to view logs and troubleshoot any issues in real-time.

Optionally, set up alerts or notifications for failures using n8n’s built-in tools or integrations.

9. FAQs

Q: Can I use this workflow for videos or GIFs?

A: This workflow specifically checks for photos in Telegram messages. To handle videos or GIFs, you’d need to adjust the Switch node to detect those media types and potentially use a different OpenAI or AI model for analysis.

Q: Does this consume OpenAI credits?

A: Yes, each image analyzed consumes OpenAI API credits based on your OpenAI pricing and usage.

Q: Is my data safe sending images to OpenAI?

A: Images are securely transmitted via encrypted API calls. However, always abide by your organization’s data privacy policies.

10. Conclusion

By following this guide, you’ve built an automated image analysis tool integrated with Telegram using n8n and OpenAI. This workflow identifies images, analyzes them smartly, and returns insightful responses instantly.

Alex can now save hours weekly, reduce manual errors, and keep the Telegram group lively and well-managed. Next steps could include adding multilingual support, logging results to Google Sheets for audit, or expanding to handle videos and text analysis.

This step-by-step, beginner-friendly guide ensures even n8n newcomers can deploy advanced AI-driven image response automation quickly and effectively.

Promoted by BULDRR AI

Related Workflows

Automate Viral UGC Video Creation Using n8n + Degaus (Beginner-Friendly Guide)

Learn how to automate viral UGC video creation using n8n, AI prompts, and Degaus. This beginner-friendly guide shows how to import, configure, and run the workflow without technical complexity.
Form Trigger
Google Sheets
Gmail
+37
Free

AI SEO Blog Writer Automation in n8n (Beginner Guide)

A complete beginner guide to building an AI-powered SEO blog writer automation using n8n.
AI Agent
Google Sheets
httpRequest
+5
Free

Automate CrowdStrike Alerts with VirusTotal, Jira & Slack

This workflow automates processing of CrowdStrike detections by enriching threat data via VirusTotal, creating Jira tickets for incident tracking, and notifying teams on Slack for quick response. Save hours daily by transforming complex threat data into actionable alerts effortlessly.
scheduleTrigger
httpRequest
jira
+5
Free

Automate Telegram Invoices to Notion with AI Summaries & Reports

Save hours on financial tracking by automating invoice extraction from Telegram photos to Notion using Google Gemini AI. This workflow extracts data, records transactions, and generates detailed spending reports with charts sent on schedule via Telegram.
lmChatGoogleGemini
telegramTrigger
notion
+9
Free

Automate Email Replies with n8n and AI-Powered Summarization

Save hours managing your inbox with this n8n workflow that uses IMAP email triggers, AI summarization, and vector search to draft concise replies requiring minimal review. Automate business email processing efficiently with AI guidance and Gmail integration.
emailReadImap
vectorStoreQdrant
emailSend
+12
Free

Automate Email Campaigns Using n8n with Gmail & Google Sheets

This n8n workflow automates personalized email outreach campaigns by integrating Gmail and Google Sheets, saving hours of manual follow-up work and reducing errors in email sequences. It ensures timely follow-ups based on previous email interactions, optimizing communication efficiency.
googleSheets
gmail
code
+5
Free