Category: Automations › WhatsApp, SMS & Messaging · Best for: Communities and creators on Telegram · Platform: n8n · Steps: 29
What it does
A Telegram bot that understands text, voice notes and pictures, and replies.
A WebHook allows your Telegram bot to automatically receive updates instead of manually polling the Bot API.
Works with: OpenAI, Text Classifier, Telegram
What you get
- The n8n workflow file (
workflow.json), ready to import - This setup guide
- The list of fields to change for your own accounts (see Install below)
- Email support if you get stuck
Before you start
-
An n8n account. Easiest: n8n Cloud (free trial). Self-host for free with Docker:
docker run -it --rm -p 5678:5678 -v n8n_data:/home/node/.n8n docker.n8n.io/n8nio/n8n, then open http://localhost:5678. -
Accounts and API keys for these services:
- Telegram bot token from @BotFather: how to connect (used by Error message, Get Audio File, Get Image, Test Webhook Status, Production Webhook Status, Audio Task Message, Audio Other Message, Text Task Message, Text Other Message, Image Message, Get Webhook Status)
- OpenAI API key: how to connect (used by gpt-4o-mini, Analyze Image, Transcribe Recording, gpt-4o-mini1)
Install
- In n8n, click Create workflow (top right).
- Click the ⋯ menu → Import from file and choose
workflow.json. Or open the file, copy everything and paste it onto the empty canvas with Ctrl/Cmd + V. - Open each node with a red warning triangle and pick or create the matching credential from the list above.
- Point these fields at your own sheets, chats and accounts:
- Error message →
chatId: choose your own - Test Webhook Status →
chatId: choose your own - Production Webhook Status →
chatId: choose your own - Audio Task Message →
chatId: choose your own - Audio Other Message →
chatId: choose your own - Text Task Message →
chatId: choose your own - Text Other Message →
chatId: choose your own - Image Message →
chatId: choose your own - Get Webhook Status →
chatId: choose your own
- Error message →
- Click Save.
Test it
- Click Test workflow (or Execute workflow). Listen for Telegram Events starts it. Trigger it once with real sample data.
- Click each node to check its output. A green tick means the step worked.
- Fix any red node: it's almost always a credential or a field that still points at a sheet or chat that isn't yours.
Go live
Toggle Active (top right). From now on it runs on its own. Check Executions in the left sidebar to see every run.
How it works, step by step
- Listen for Telegram Events starts the workflow (Webhook).
- Telegram Token & Webhooks reshapes the data for the next step.
- gpt-4o-mini uses AI (OpenAI).
- gpt-4o-mini1 uses AI (OpenAI).
- Validation reshapes the data for the next step.
- Set Webhook Production URL calls an external API (=https://api.telegram.org/{{ $json.token }}/setWebhook).
- Set Webhook Test URL calls an external API (=https://api.telegram.org/{{ $json.token }}/setWebhook).
- Get Telegram Webhook Info calls an external API (=https://api.telegram.org/{{ $json.token }}/getWebhookInfo).
- Text Classifier Audio uses AI (Text Classifier).
- Text Classifier uses AI (Text Classifier).
- Check User & Chat ID checks a condition and routes items accordingly.
- Production Webhook Status uses Telegram.
- Test Webhook Status uses Telegram.
- Get Webhook Status uses Telegram.
- Audio Task Message uses Telegram.
- Audio Other Message uses Telegram.
- Text Task Message uses Telegram.
- Text Other Message uses Telegram.
- Message Router checks a condition and routes items accordingly.
- Error message uses Telegram.
- Get Audio File uses Telegram to file.
- Edit Fields reshapes the data for the next step.
- Image Schema reshapes the data for the next step.
- Transcribe Recording uses AI (OpenAI).
- Get Image uses Telegram to file.
- Extract from File to Base64 uses Extract From File to binaryToPropery.
- Convert to Image File uses Convert To File to toBinary.
- Analyze Image uses AI (OpenAI).
- Image Message uses Telegram.
India & US notes
India: use the official WhatsApp Business Cloud API from Meta (free to start, pay per conversation). Unofficial WhatsApp tools can get your number banned. US: the same API works; SMS via Twilio is a good fallback.
Extra setup notes
These notes are also on the canvas as yellow sticky notes:
Receive Telegram Message with Webhook
Telegram Webhook Tools
Setting your Telegram Bot WebHook the Easy Way
Process Audio
Process Image
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 BotFatherurl_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:
{
"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.
Process Text
Validate Telegram User
Webhook Status
Set Webhook for Testing
Set Webhook for Production
Troubleshooting
- "Credentials not found": open the node and select your credential again.
- Google "access blocked": in Google Cloud, add your email as a test user on the OAuth consent screen.
- Webhook not firing: copy the node's Production URL (not Test URL) into the other app, and make sure the workflow is Active.
- AI node errors: check your API key has billing enabled and the model name exists on your plan.
- Nothing happens on schedule: the workflow must be Active, and self-hosted n8n must stay running.
Need help?
Reply to your Morning Method order email and we'll help you get it running.
© Morning Method