Guide Menu expand_more

telegram

OpenClaw Telegram Setup & Safety

Connect OpenClaw to Telegram safely using BotFather. Learn how to restrict access using dmPolicy and allowlists to prevent unauthorized usage.

Difficulty
beginner
Duration
20-30 minutes
Tested On
Telegram Bot API
Access Mode
BotFather Token
verified
Status readiness check
Pre-Flight Approved
Risk rating medium
Gateway status Private
Proceed with caution Ensure you enable an allowlist or pairing mode. Do not leave the bot publicly accessible without access controls.

Who this is for

This guide is for OpenClaw users who want to connect a Telegram bot to their Gateway to interact with AI models via chat.

Prerequisites

  • An active Telegram account.
  • Access to @BotFather on Telegram.
  • A running OpenClaw Gateway instance.

Why Telegram is risky out of the box

Telegram bots are publicly discoverable. If you build an OpenClaw bot that connects to a paid LLM API (like OpenAI or Anthropic) and you leave it unrestricted, anyone can message your bot and drain your API credits.

Configuration Steps

  1. Create the Bot via BotFather

    Message @BotFather on Telegram, send /newbot, and follow the prompts. Copy the HTTP API Token provided.

  2. Add the Telegram Channel

    Use the OpenClaw CLI to add Telegram. When asked for the token, paste it securely.

    bash
    openclaw channel add telegram
  3. Find your Telegram User ID

    To restrict the bot to yourself, you need your numeric Telegram User ID. You can find this by messaging @userinfobot or using the OpenClaw logs when you send a test message.

  4. Update your configuration

    Open your claw.config.json and ensure your allowlist array contains your numeric User ID.

    "channels": {
      "telegram": {
        "enabled": true,
        "token": "YOUR_BOT_TOKEN_HERE",
        "dmPolicy": "allowlist",
        "allowlist": [123456789]
      }
    }
  5. Restart the Gateway

    Restart OpenClaw to apply the new access controls.

    bash
    openclaw restart
    [OK] Telegram channel connected as @YourBotName

Bad Output / Common Mistakes

  • Bot not replying at all: Check if you added the correct User ID. If your logs say “Rejected incoming Telegram message”, your security policy is working, but your ID is missing from the list.
  • Error 409 Conflict: You have another script or server running the same bot token.

Rollback / Undo

If you need to disconnect the Telegram bot or suspect your token was compromised:

  • Remove the channel:
    bash
    openclaw channel remove telegram
  • Revoke the token: Message @BotFather, select your bot, and choose Revoke Token to invalidate the old credentials.

When to ask for help

If your bot needs to operate in a group chat with complex permission requirements (e.g., only answering when mentioned, or only answering admins), setting up the right policy can be tricky. Request a Telegram Architecture Session for guidance.

Sources

ClawReady.in is an independent educational resource and setup service. It is not affiliated with, endorsed by, or operated by OpenClaw.