Create Telegram Credentials in n8n: Step-by-Step Guide

Learn how to create and configure Telegram Bot credentials in n8n, find chat IDs, test sending messages, and set up receiving messages via getUpdates or webhook.

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 `` with the token from BotFather. The JSON response will include entries like:

    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:

  • getUpdates (polling): n8n periodically calls the getUpdates API to pull new messages. Simple to set up for development or when you can’t host a public URL.
  • Webhook: Telegram pushes messages to a public URL using `setWebhook`. Faster and more scalable, but requires a public HTTPS endpoint reachable by Telegram.
  • 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

  • Security: Store the bot token as a credential in n8n — do not hard-code it in workflows. Limit access to n8n credentials.
  • Bot permissions: For channels, add the bot as an admin to allow posting. For groups, the bot must be a member and not restricted.
  • Chat ID format: Public channels can use `@username`. Private group or channel IDs often start with `-100` and are large negative numbers.
  • Rate limits: Telegram enforces rate limits. Avoid spamming messages; batch or queue messages if needed.
  • Error handling: Add retry/error-logic in n8n (e.g., execute node on failure, use wait/IF nodes). Check HTTP errors and examine Telegram API `description` messages.
  • Testing: Use getUpdates during development. For production, prefer webhooks for lower latency.
  • Common issues:

  • 403 Forbidden: Bot has been blocked or not added to the chat.
  • Bad Request: Wrong chat id or message format (e.g., trying to send to a user who hasn’t started the bot).
  • 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:

  • Build a real workflow (e.g., notifications from your app, alerts from monitoring systems, or a simple chatbot).
  • Add error handling and rate-limit awareness.
  • If self-hosting n8n, secure it with HTTPS so you can use webhooks in production.

If you run into a specific error, share the error message and relevant logs and I can help troubleshoot further.

Related Posts