Introduction
This guide walks you through creating Telegram credentials for n8n so you can send and receive messages with a Telegram Bot. You’ll learn how to create a bot with BotFather, retrieve the bot token, discover chat IDs (for users, groups, and channels), add the credentials in n8n, and test a simple workflow. This tutorial is beginner-friendly and includes code examples, best practices, and troubleshooting tips.
What you’ll need
- An n8n instance (cloud or self-hosted) with a running UI
- A Telegram account
- Basic familiarity with the n8n editor
Overview of steps
1. Create a Telegram bot with BotFather
2. Retrieve the bot token
3. Discover the chat ID(s) you want to message
4. Create Telegram credentials in n8n
5. Build and test a simple workflow that sends a message
6. (Optional) Configure receiving messages using getUpdates or webhooks
—
1. Create a Telegram bot (BotFather)
1. Open Telegram and search for @BotFather.
2. Start a conversation and send `/newbot`.
3. Follow prompts to give your bot a name and a username (the username must end with “bot”, e.g. `my_automation_bot`).
4. After creation, BotFather will reply with a token in this format:
123456789:ABCdefGhIjKlmNO_PQRsTuvWXyZ
Save this token securely — it is the secret your n8n workflow will use to control the bot.
—
2. Find the chat ID you want to send messages to
There are a few ways to get a chat id for a user, group, or channel.
Option A — Quick method using the Telegram API (recommended for development):
1. Send a message to your bot (or add the bot to the group/channel and send a message there).
2. Use getUpdates to retrieve the recent messages and see the chat.id.
Example:
curl "https://api.telegram.org/bot/getUpdates"
Replace `
json
{
"ok": true,
"result": [
{
"update_id": 123456789,
"message": {
"message_id": 12,
"from": { "id": 987654321, "is_bot": false, "first_name": "Alice" },
"chat": { "id": 987654321, "first_name": "Alice", "type": "private" },
"text": "hello"
}
}
]
}
The `chat.id` value is what you need (for groups and channels you’ll often see a negative id like `-1001234567890`).
Option B — Use helper bots: search and message `@getidsbot` or `@userinfobot` and follow instructions — they return your chat or group id.
Option C — For public channels, you can use the channel username instead of the numeric id (e.g. `@mychannelusername`).
—
3. Create Telegram credentials in n8n
1. Log into n8n and open the left-hand menu.
2. Click on “Credentials” → “New Credential”.
3. Search for “Telegram” and select “Telegram Bot” (or similarly labeled credential type).
4. Paste your BotFather token into the `botToken` field.
5. Optionally give the credential a descriptive name (e.g., “Telegram – My Automation Bot”).
6. Save the credential.
In many versions of n8n you can also test the credential by creating a quick workflow and using the Telegram node to send a message.
—
4. Build and test a simple workflow to send a message
1. Create a new workflow in n8n.
2. Add the Telegram node (or `Telegram` resource) and set the operation to `sendMessage` (naming may vary by n8n version).
3. In the node’s Credentials dropdown select the Telegram credentials you created.
4. Set `chatId` to the numeric chat id you found (or use a channel username like `@mychannelusername`).
5. Set `text` to a test message, e.g. “Hello from n8n!”.
6. Execute the node (or run workflow) to send the message.
Example sending message via Telegram HTTP API (for debugging outside n8n):
curl -X POST "https://api.telegram.org/bot/sendMessage" \
-d chat_id= \
-d text="Hello from n8n"
If it succeeds, your bot will deliver the message to the chat. If you see `403 Forbidden` or `Bad Request`, check that the bot is a member of the group/channel and that the chat id is correct.
—
5. Receive messages: Polling vs Webhook
Telegram supports two ways to receive messages in n8n:
To set a webhook manually:
curl "https://api.telegram.org/bot/setWebhook?url=https://your-n8n-domain/webhook/telegram"
Replace `https://your-n8n-domain/webhook/telegram` with your webhook receiver URL. If you use n8n’s Telegram Trigger node and your n8n is publicly reachable, it will often handle webhook setup for you.
—
Best practices and troubleshooting
Common issues:
—
Example n8n expression usage
If you receive a message in a Telegram Trigger and want to reply using the chat id from the trigger, use an expression for chatId:
{{$json["message"]["chat"]["id"]}}
Or if your trigger provides `chat.id` at root:
{{$json["chat"]["id"]}}
This lets you dynamically route replies to the correct chat.
—
Conclusion and next steps
You now know how to create a Telegram bot in BotFather, retrieve the token and chat IDs, add Telegram credentials in n8n, send test messages, and choose between polling and webhooks to receive messages. Next steps:
If you run into a specific error, share the error message and relevant logs and I can help troubleshoot further.