ChatGPTCreativeWritingAI score · PendingAI-assisted edit · no obvious prompt-injection riskn8n.io

🤖 Telegram Messaging Agent for Text/Audio/Images

Receive Telegram text/voice/image messages via n8n workflow, classify or analyze with AI, and auto-reply

Some experienceStepsWorkflowPromptTip
Who
Builders with an n8n instance, Telegram Bot, and OpenAI API credentials
You get
Bot auto-detects message type (text/voice/image), runs AI classification or content analysis, and returns results to the user
You need
n8n · telegram

Constraints

Prerequisites: accessible n8n instance (public HTTPS address required for Webhook), Telegram Bot Token (from BotFather), OpenAI API Key. Credential types: telegramApi, openAiApi. Cost: OpenAI API pay-per-use; n8n self-hosted or cloud pricing varies by plan.

What they did

Author joe published a workflow template on n8n that demonstrates how to build a Telegram bot handling text, voice, and image messages simultaneously. The template contains 39 nodes, using Webhook to receive messages, IF node for user validation, Switch node for message-type routing, OpenAI nodes for voice transcription/image analysis/text classification, and Telegram nodes to return results.

How it went

The template claims real-time message reception, multimodal processing, AI classification, and image analysis capabilities (author_report). As of collection, the template had 55,057 views and status published.

Worth knowing

1) This site has not imported or run the workflow; reproduction results are unknown. 2) User validation uses hard-coded names and IDs; replace with actual authorized users for production. 3) Voice transcription uses OpenAI Whisper and image analysis uses GPT-4o-mini, both incurring API costs. 4) Webhook requires a public HTTPS address; local testing needs a tunnel tool. 5) The Get Webhook Status node uses expression ={{ JSON.stringify($json.result, null, 2) }} for formatted output only, not an execution prompt.

n8n workflow template

Structure checked · Not run-tested

Use “Import from File” in n8n, or copy the JSON and paste it into the editor. Connect your own accounts, then try test data. The template is inactive by default.

Setup and test checklist

Credentials to connect

  • Error message node: connect Telegram API credentials.
  • gpt-4o-mini node: connect OpenAI API credentials.
  • Get Audio File node: connect Telegram API credentials.
  • Get Image node: connect Telegram API credentials.
  • Analyze Image node: connect OpenAI API credentials.
  • Transcribe Recording node: connect OpenAI API credentials.
  • gpt-4o-mini1 node: connect OpenAI API credentials.
  • Test Webhook Status node: connect Telegram API credentials.
  • Production Webhook Status node: connect Telegram API credentials.
  • Audio Task Message node: connect Telegram API credentials.
  • Audio Other Message node: connect Telegram API credentials.
  • Text Task Message node: connect Telegram API credentials.
  • Text Other Message node: connect Telegram API credentials.
  • Image Message node: connect Telegram API credentials.
  • Get Webhook Status node: connect Telegram API credentials.

Configuration to replace

  • Source template is n8n public workflow #2751 (~39 nodes). Keep inactive after import; verify triggers, expressions and external API endpoints.
  • Sticky-note guidance is informational; replace placeholders with your own accounts, sheet schemas or channel IDs.

Test input and expected output

  • Manually run the main path once in a test workspace and confirm credentialed nodes authenticate without errors.
  • Drive one synthetic/redacted sample through and check output fields and downstream writes before enabling in production.

Template changes

  • Author credential bindings, webhookId and execution data are removed; the workflow is inactive. Nodes, connections and original prompts are preserved. Not run-tested in n8n.
  • No business-logic edits; verify keys, quotas and privacy compliance before use.

Template retrieved: 2026-10-25

Steps

  1. Configure Telegram Webhook

    Configure the Telegram Bot Webhook address in n8n so the bot can receive messages in real time. Set up both test and production endpoints, then verify the Webhook status.

    Setup guidance · Source text。n8n workflow Sticky Note1 node content; guides Webhook configuration

    # How to set up a Telegram Bot WebHook
    
    ## WebHook Setup Process
    
    **Basic Concept**
    A WebHook allows your Telegram bot to automatically receive updates instead of manually polling the Bot API.
    
    **Setup Method**
    To set a WebHook, make a GET request using this URL format:
    ```
    https://api.telegram.org/bot{my_bot_token}/setWebhook?url={url_to_send_updates_to}
    ```
    Where:
    - `my_bot_token`: Your bot token from BotFather
    - `url_to_send_updates_to`: Your HTTPS endpoint that handles bot updates
    
    
    **Verification**
    To verify the WebHook setup, use:
    ```
    https://api.telegram.org/bot{my_bot_token}/getWebhookInfo
    ```
    
    A successful response looks like:
    ```json
    {
     "ok": true,
     "result": {
       "url": "https://www.example.com/my-telegram-bot/",
       "has_custom_certificate": false,
       "pending_update_count": 0,
       "max_connections": 40
     }
    }
    ```
    
    
    This method provides a simple and efficient way to handle Telegram bot updates automatically through webhooks rather than manual polling.
  2. Receive message and validate user

    Receive Telegram messages via the Webhook node, then use a Set node to define allowed user info (first name, last name, user ID), and an IF node to match the sender. Users who fail validation receive an error message.

  3. Route message type

    Use a Switch node to auto-route by message content: voice field → audio branch, text field → text branch, photo field → image branch, everything else → error handling.

  4. Process text messages

    Extract message text, then use a Text Classifier node (connected to GPT-4o-mini) to judge whether the message is about creating a task/todo. If classified as task, reply with 'Task message: <content>'; otherwise reply with 'Other message: <content>'.

    Execution prompt · Source text。Text Classifier node categories[0].description

    If the message is about about creating a task/todo

    Execution prompt · Source text。Text Classifier node categories[1].description

    If the message is not about creating a task/todo
  5. Process voice messages

    Download the voice file from Telegram, use the OpenAI node's audio/transcribe feature to convert speech to text. Then route through Text Classifier Audio (connected to GPT-4o-mini) as task or other, and send the corresponding formatted reply.

    Execution prompt · Source text。Text Classifier Audio node categories[0].description

    If the message is about about creating a task/todo

    Execution prompt · Source text。Text Classifier Audio node categories[1].description

    If the message is not about creating a task/todo
  6. Process image messages

    Extract image file_id and caption, download the image from Telegram, convert to base64, then use the OpenAI node's image/analyze feature (model GPT-4O-MINI) to analyze the image content, and finally return the analysis result to the user.

Prompt you can copy

Setup guidance · Editorial suggestion。交给搭建助手,先确认输入和权限

This block is the prompt. Ads are never placed here.

Please build this Telegram multimodal messaging agent using the following n8n template. First confirm you have: 1) a publicly accessible n8n instance; 2) a Telegram Bot Token; 3) an OpenAI API Key. Then configure the Webhook, user validation fields, message router, and AI node credentials step by step. After setup, send a test text message via the test Webhook to verify the flow.

Replace [your-telegram-bot-token], [your-url], [your-endpoint] with actual values; user validation fields must match your Telegram account info

Source

🤖 Telegram messaging agent for text/audio/images · joe · n8n.io · 2025-01-18

Comments & feedback

Tried this method? Share results, problems or improvements. Comments appear after moderation. Please avoid sensitive information.

Loading…

    Related