Connect Telegram Bot

Create and connect a Telegram bot to Clawdbot. Step-by-step guide to set up AI-powered replies in Telegram.

Easy ⏱️ 5 min

Overview

This guide will help you create a Telegram bot and connect it to Clawdbot, enabling:

  • Automatic AI replies to messages
  • Group chat AI integration
  • Voice message processing
  • Image and file handling

Prerequisites

  • Clawdbot installed on your machine
  • A Telegram account
  • Telegram app installed (mobile or desktop)

Step 1: Create a Telegram Bot

First, you need to create a bot through Telegram’s BotFather:

  1. Open Telegram and search for @BotFather
  2. Start a chat and send /newbot
  3. Follow the prompts:
    • Enter a name for your bot (e.g., “My AI Assistant”)
    • Enter a username (must end in “bot”, e.g., “myai_assistant_bot”)
  4. BotFather will give you an API token — copy this token

⚠️ Important: Keep your bot token secret. Anyone with the token can control your bot.


Step 2: Add the Bot to Clawdbot

Run this command in your terminal:

clawdbot channels add telegram

When prompted, paste your bot token.

Alternatively, use the setup wizard:

clawdbot onboard

Select Add messaging channelTelegram, then enter your token.


Step 3: Configure Bot Settings

After adding the bot, you can configure its behavior:

# Set who can use the bot (optional but recommended)
clawdbot config set telegram.allowList "123456789,987654321"

Replace the numbers with Telegram user IDs of people allowed to use the bot.

Finding Your Telegram User ID

  1. Search for @userinfobot on Telegram
  2. Start a chat — it will reply with your user ID

Step 4: Start the Gateway

Launch Clawdbot:

clawdbot gateway

Your Telegram bot is now active! Send it a message to test.


Group Chat Setup

To use your bot in group chats:

Enable Group Mode

clawdbot config set telegram.groups.enabled true

Add Bot to Group

  1. Open your Telegram group
  2. Click on the group name → Add Members
  3. Search for your bot’s username and add it
  4. Make the bot an admin (required for reading messages)

Trigger Behavior

By default, the bot responds when:

  • It’s mentioned with @username
  • Someone replies to one of its messages

To make it respond to all messages:

clawdbot config set telegram.groups.replyToAll true

Advanced Configuration

Custom Commands

Add custom bot commands that appear in Telegram’s menu:

clawdbot config set telegram.commands '[
  {"command": "help", "description": "Show help message"},
  {"command": "reset", "description": "Reset conversation"}
]'

Webhook Mode (for Servers)

If running on a server with a public IP:

clawdbot config set telegram.mode webhook
clawdbot config set telegram.webhookUrl "https://your-domain.com/telegram/webhook"

Troubleshooting

Bot Not Responding

  1. Check the gateway is running: clawdbot status
  2. Verify the token: clawdbot config get telegram.token
  3. Make sure you’re in the allow list (if configured)

“Unauthorized” Error

Your bot token may be invalid. Get a new token from @BotFather:

  1. Chat with @BotFather
  2. Send /mybots
  3. Select your bot
  4. Click API TokenRevoke current token
  5. Get the new token and update Clawdbot

Bot Can’t Read Group Messages

Make sure the bot is an admin in the group. In Telegram:

  1. Open group settings
  2. Go to Administrators
  3. Add your bot and enable at least “Read messages”

Next Steps