Telegram Setup
Overview
Section titled “Overview”Telegram is the recommended channel for Clawdbot. It offers the most stable connection, full feature support, and the easiest setup process.
Why Telegram?
Section titled “Why Telegram?”- Official Bot API: No risk of account restrictions
- Rich features: Inline mode, groups, media support
- No phone requirement: Works independently
- Free and unlimited: No message limits
Prerequisites
Section titled “Prerequisites”- Clawdbot installed
- Telegram account
-
Create a Telegram Bot
- Open Telegram and search for @BotFather
- Send
/newbot - Choose a name (e.g., “My Clawdbot”)
- Choose a username (must end in
bot, e.g.,my_clawdbot_bot) - Copy the API token provided
-
Configure Clawdbot
Edit
.env:Terminal window TELEGRAM_ENABLED=trueTELEGRAM_BOT_TOKEN=1234567890:ABCdefGHIjklMNOpqrsTUVwxyz -
Start Clawdbot
Terminal window python -m clawdbot -
Test the Bot
- Find your bot in Telegram by its username
- Send
/start - Send any message
Configuration Options
Section titled “Configuration Options”# Required: Bot token from BotFatherTELEGRAM_BOT_TOKEN=your_token_here
# Enable/disable Telegram channelTELEGRAM_ENABLED=true
# Rate limiting (messages per minute per user)TELEGRAM_RATE_LIMIT=20
# Allow group chatsTELEGRAM_GROUPS_ENABLED=true
# Only respond when mentioned in groupsTELEGRAM_GROUP_MENTION_ONLY=true
# Allowed users (comma-separated Telegram user IDs, empty = all)TELEGRAM_ALLOWED_USERS=123456789,987654321
# Admin users (can use special commands)TELEGRAM_ADMIN_USERS=123456789Features
Section titled “Features”Commands
Section titled “Commands”Built-in commands (customizable):
| Command | Description |
|---|---|
/start | Begin interaction with the bot |
/help | Show available commands |
/reset | Clear conversation history |
/settings | User settings (if implemented) |
Inline Mode
Section titled “Inline Mode”Enable inline queries for quick access from any chat:
- Configure with @BotFather:
/setinline - Set placeholder text
- Users can type
@yourbot queryin any chat
# In .envTELEGRAM_INLINE_ENABLED=trueGroup Chat Support
Section titled “Group Chat Support”Clawdbot works in Telegram groups:
# In .envTELEGRAM_GROUPS_ENABLED=true
# Only respond when @mentionedTELEGRAM_GROUP_MENTION_ONLY=trueMedia Support
Section titled “Media Support”| Media Type | Receive | Send |
|---|---|---|
| Text | ✅ | ✅ |
| Images | ✅ | ✅ |
| Voice | ✅ (transcribed) | ✅ (with TTS) |
| Documents | ✅ | ✅ |
| Stickers | ✅ | ❌ |
| Location | ✅ | ❌ |
Keyboard & Buttons
Section titled “Keyboard & Buttons”Clawdbot can send interactive elements:
- Inline keyboards
- Reply keyboards
- Custom buttons (via plugins)
Advanced Configuration
Section titled “Advanced Configuration”Webhook Mode
Section titled “Webhook Mode”For production, use webhooks instead of polling:
# In .envTELEGRAM_WEBHOOK_ENABLED=trueTELEGRAM_WEBHOOK_URL=https://your-domain.com/webhook/telegramTELEGRAM_WEBHOOK_PORT=8443Multiple Bots
Section titled “Multiple Bots”Run multiple Telegram bots from one Clawdbot instance:
TELEGRAM_BOTS=bot1,bot2TELEGRAM_BOT1_TOKEN=token1TELEGRAM_BOT2_TOKEN=token2Custom Commands
Section titled “Custom Commands”Add custom commands via configuration or plugins:
# In a plugin@clawdbot.command("weather")async def weather_command(message): # Custom implementation passTroubleshooting
Section titled “Troubleshooting”Bot Not Responding
Section titled “Bot Not Responding”- Verify token is correct
- Check logs for errors:
Terminal window LOG_LEVEL=DEBUG python -m clawdbot - Ensure bot isn’t blocked or deleted
- Test token with Telegram API directly:
Terminal window curl "https://api.telegram.org/bot<TOKEN>/getMe"
“Unauthorized” Error
Section titled ““Unauthorized” Error”Your token is invalid. Get a new one from @BotFather.
Bot Works in DM but Not Groups
Section titled “Bot Works in DM but Not Groups”- Disable privacy mode: @BotFather →
/setprivacy→ Disable - Or ensure
TELEGRAM_GROUP_MENTION_ONLY=trueand mention the bot
Rate Limit Errors
Section titled “Rate Limit Errors”Telegram limits are generous, but if hit:
- Reduce
TELEGRAM_RATE_LIMIT - Implement request queuing
- Check for message loops
Messages Delayed
Section titled “Messages Delayed”- Check network latency
- Consider webhook mode for faster delivery
- Verify server isn’t overloaded
Security Best Practices
Section titled “Security Best Practices”- Keep token secret: Never commit to version control
- Restrict users: Set
TELEGRAM_ALLOWED_USERSfor private bots - Use HTTPS: For webhook mode
- Monitor usage: Watch for abuse in public bots
Example Conversation
Section titled “Example Conversation”User: /startBot: Hello! I'm Clawdbot, your AI assistant powered by Claude. How can I help you today?
User: Can you explain quantum computing in simple terms?Bot: Of course! Think of quantum computing like this...
User: /resetBot: Conversation cleared. Fresh start! What would you like to discuss?BotFather Commands Reference
Section titled “BotFather Commands Reference”Useful @BotFather commands for customization:
| Command | Purpose |
|---|---|
/setname | Change bot’s display name |
/setdescription | Set bot description |
/setabouttext | Set “About” section |
/setuserpic | Set bot profile picture |
/setcommands | Define command list |
/setprivacy | Toggle group privacy mode |
/setinline | Enable inline mode |