Automate Telegram Messaging: Text, Audio & Image Processing with n8n

This workflow automates the processing of Telegram messages including text, audio, and images, validating users and handling tasks intelligently. It saves time by automating message classification, transcription, image analysis, and bot webhook setup using n8n nodes.
telegram
webhook
lmChatOpenAi
+27
Workflow Identifier: 1629
NODES in Use: Webhook, If, Telegram, Http Request, Set, Switch, Convert To File, Extract From File, LangChain OpenAi, Set, Telegram, Telegram, Telegram, Telegram, Telegram, Telegram, Telegram, LangChain TextClassifier, LangChain TextClassifier, Set, Telegram, Telegram, Telegram, Telegram, Telegram, Telegram, Telegram, Telegram, Convert To File, Extract From File

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

Learn how to Build this Workflow with AI:

Visit through Desktop for Best experience

What This Workflow Does

This workflow listens for Telegram messages that have text, voice notes, or images.
It checks if the message sender is allowed to talk to the bot.
Then, it sorts messages by type and uses AI to understand or analyze each one.
Finally, it sends replies based on the message content.

This helps save time by automating replies and understanding tasks without manual work.


Tools and Services Used

  • Telegram Bot API: Receives user messages.
  • OpenAI API: Transcribes voice messages and classifies text messages.
  • n8n Workflows: Automates webhook listening, message routing, and sending replies.
  • LangChain OpenAI: Classifies messages as tasks or others.
  • Secure HTTPS Webhook URL: Ensures safe communication between Telegram and n8n.

Inputs, Processing Steps, and Outputs

Inputs

  • Incoming Telegram messages including text, audio (voice notes), and images.
  • Sender information to check authorization.

Processing Steps

  • Webhook node listens for incoming Telegram messages.
  • Validation node checks if the user sending the message is authorized.
  • Message Router sends messages to different paths based on type: text, audio, or image.
  • Audio messages are fetched, transcribed using OpenAI, and then classified.
  • Text messages are extracted and classified using LangChain text classifier.
  • Image messages are downloaded, converted to proper format, and sent to OpenAI’s GPT-4o Mini for analysis.
  • Replies are formed and sent back to Telegram users based on classification results.
  • Webhook setup nodes manage testing and production webhook URLs via Telegram API.

Outputs

  • Appropriate Telegram replies based on message type and classification.
  • Status messages for webhook setup confirmation.

Beginner Step-by-Step: How to Use This Workflow in n8n

Download and Import Workflow

  1. Download the workflow file using the Download button on this page.
  2. In n8n editor, click on “Import from File”.
  3. Select the downloaded file to import the workflow.

Configure Credentials and Settings

  1. Add your Telegram Bot API token in the Telegram Token & Webhooks node under the token field.
  2. Enter your secure public HTTPS webhook URLs for both test and production environments.
  3. Add your OpenAI API Key in all nodes that require AI services.
  4. Update user IDs and names in the Validation node to include authorized Telegram users.
  5. Change any channel IDs, emails, or other identifiers if needed for your setup.

Test and Activate

  1. Send test messages (text, voice, image) to your Telegram bot. Confirm workflow processes messages and replies correctly.
  2. Adjust message texts or classification prompts if needed.
  3. When ready, activate the workflow by toggling the switch to “ACTIVE”.
  4. Set the webhook URL you want the bot to use by triggering the Set Webhook Production URL node for live usage.

You can also explore self-host n8n if you want more control over hosting the automation.


How the Workflow Works – Input → Process → Output

Input

Telegram messages arrive through the Webhook node.
Messages can be text, voice messages, or images.

Process

First, the Validation node checks if the sender is allowed.
Then, Message Router routes messages by type.

Audio files get downloaded, sent to OpenAI for transcription, then classified as task or other.
Text messages get extracted and classified in LangChain OpenAI nodes.

Images are downloaded, converted to base64 and back for AI readiness, then analyzed by GPT-4o Mini model.

Output

After classification and analysis, the workflow sends tailored replies via Telegram API nodes.
Webhook setup and status nodes manage Telegram bot webhook URLs for testing and production environments.


Customization Ideas

  • Add more users in the Validation node to widen who can use the bot.
  • Change classification labels from “task” and “other” to more detailed categories in text classifiers.
  • Edit response messages to add personal style or brand voice in message nodes.
  • Add new message type routes like video or documents in Message Router to support more media.

Common Problems and Fixes

  • Error: “Unable to process your message.” reply.
    Reason: User not authorized or message format unmatched.
    Fix: Check the Validation node user data matches Telegram sender. Confirm message types handled by Message Router.
  • Error: No webhook updates.
    Reason: Bad webhook URL or Bot token.
    Fix: Verify HTTPS webhook URLs and tokens in Telegram Token & Webhooks. Use Get Telegram Webhook Info to confirm webhook is active.
  • Error: Transcription fails or texts unclear.
    Reason: Poor audio quality or OpenAI key issues.
    Fix: Test clear audio, check API key and limits.

Pre-Production Checklist

  • Make sure Telegram Bot token is set correctly in Telegram Token & Webhooks.
  • Try webhook URLs with test URL before switching to production URL.
  • Verify the Validation node user info matches the Telegram users.
  • Send test messages of all types and verify routing and replies.
  • Check OpenAI API credentials for transcription and classification work.
  • Backup workflow before big changes to save your work.

Deployment Guide

After testing, turn the workflow on by switching it to “ACTIVE”.
Use the status nodes to watch for webhook health and chat activity.

Set webhook URL in Set Webhook Production URL node and enable that webhook.
Disable test webhook to avoid message conflicts.

Check status replies regularly to see webhook connection updates.


Summary of Benefits and Results

✓ Saves time by automating Telegram message replies.
✓ Checks user authorization automatically to prevent errors.
✓ Classifies text and audio messages to spot tasks easily.
✓ Analyzes image content with AI for smart replies.
✓ Handles webhook setup and status for reliable bot operation.
✓ Easy to test before moving to live production.


Frequently Asked Questions

Yes. The workflow can replace OpenAI LangChain nodes with other AI providers supported by n8n.
Yes. Transcription and classification via OpenAI API use credits based on usage.
Data is processed only within the user’s n8n environment. Using secure HTTPS and careful credential management keeps data safe.
It suits moderate message volumes but can scale with multiple workflow instances or stronger n8n setups.

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 Workflows in n8n

A complete beginner guide to building an AI 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