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
Automate Telegram messaging with n8n and Telegram

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

Learn how to Build this Workflow with AI:

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.


Automate Telegram messaging with n8n and Telegram

Visit through Desktop to Interact with the Workflow.

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 Twist Channel Creation and Messaging with n8n

This workflow automates creating and updating a channel in Twist and sending a personalized message to specific users. It eliminates manual setup errors and saves time managing Twist communications.

Automate Ideogram Image Generation with Google Sheets & Gmail

This workflow automates graphic design image generation via Ideogram AI, storing image data in Google Sheets and Google Drive, with email alerts via Gmail. It saves designers hours by automating image creation, remixing, review, and record-keeping.

Automate IT Support with Slack and OpenAI in n8n

Streamline IT support by automating Slack message handling using n8n and OpenAI. This workflow handles Slack DMs, filters bots, queries a Confluence knowledge base, and delivers AI-generated responses, improving support efficiency and response time.

Automate Crypto Analysis with CoinMarketCap & n8n AI Agent

Discover how this unique n8n workflow leverages CoinMarketCap’s multi-agent AI to deliver precise, real-time cryptocurrency insights directly via Telegram. Manage crypto data analysis efficiently with automated multi-source API integration.

Automate Gumroad to Beehiiv Subscriber Sync with n8n

Learn how to automatically add new Gumroad sales customers as Beehiiv newsletter subscribers using n8n automation. This workflow saves time by syncing sales data to Google Sheets CRM and notifying your Telegram channel instantly.

Generate On-Brand Blog Articles Using n8n and OpenAI

This workflow automates the creation of on-brand blog articles by analyzing existing company content using n8n and OpenAI. It extracts article structures and brand voice to produce consistent draft articles, saving significant content creation time.
1:1 Free Strategy Session
Your competitors are already automating. Are you still paying for it manually?

Do you want to adopt AI Automation?

Every hour your team does repetitive work, you're burning real money.
While you wait, faster businesses are cutting costs and moving quicker.
AI and automations aren't the future anymore — they're the present.

Book a live 1-on-1 session where we show you exactly which of your daily tasks can be automated — and what it’s costing you not to.