Telegram Bot Setup

Deploy your OpenClaw AI agent as a Telegram bot using the Bot API via grammY.

Overview

OpenClaw integrates with Telegram via the Bot API using the grammY library. It supports both direct messages and group chats.

Quick Setup

1. Create a Bot Token

  1. Open Telegram and search for @BotFather
  2. Send /newbot and follow the prompts
  3. Copy the bot token (format: 123:abc...)

2. Configure OpenClaw

{
  "channels": {
    "telegram": {
      "enabled": true,
      "botToken": "123:abc...",
      "dmPolicy": "pairing",
      "groups": {
        "*": {
          "requireMention": true
        }
      }
    }
  }
}

Or use an environment variable:

export TELEGRAM_BOT_TOKEN="123:abc..."

3. Login and Start

openclaw channels login telegram
openclaw gateway

4. Approve First DM

openclaw pairing list telegram
openclaw pairing approve telegram <CODE>

DM Access Control

PolicyDescription
pairing (default)New senders must be approved via pairing code
allowlistOnly allow specific sender IDs
openAllow all senders (set allowFrom: ["*"])
disabledReject all DMs
{
  "channels": {
    "telegram": {
      "dmPolicy": "allowlist",
      "allowFrom": ["tg:123456789"]
    }
  }
}

Group Chat Setup

  1. Add the bot to a Telegram group
  2. Disable privacy mode: send /setprivacy to @BotFather
  3. Or make the bot a group admin

BotFather Settings

  • /setjoingroups — Allow/deny group membership
  • /setprivacy — Control group message visibility

Features

  • ✅ Direct messages with pairing
  • ✅ Group chats with mention activation
  • ✅ Image and media support
  • ✅ Audio/voice messages
  • ✅ Sticker handling
  • ✅ Video messages

Troubleshooting

Bot not responding

  • Verify botToken is correct
  • Check openclaw gateway status
  • Run openclaw doctor --fix

Messages not received in groups

  • Disable privacy mode via /setprivacy
  • Or make the bot a group admin

Next Steps