Skip to main content

Telegram Setup

Telegram bots are easy to set up and highly customizable. Your ClawBook AI assistant can work in private chats, groups, and channels.

Prerequisites

  • Active ClawBook subscription
  • LLM provider configured
  • Telegram account

Creating Your Bot

Step 1: Talk to BotFather

  1. Open Telegram
  2. Search for @BotFather (verified with blue checkmark)
  3. Start a conversation
  4. Send /newbot

Step 2: Configure Your Bot

BotFather will ask:

  1. Bot name: My Claw Assistant (display name)
  2. Bot username: MyClaw_bot (must end in bot)

You'll receive:

Done! Congratulations on your new bot. You will find it at t.me/MyClaw_bot.

Use this token to access the HTTP API:
7123456789:AAHxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Keep your token secure and store it safely.

Step 3: Connect to ClawBook

  1. Go to IntegrationsTelegram
  2. Enter your bot token
  3. Click Connect
Bot Token: 7123456789:AAHxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Bot Username: @MyClaw_bot

Step 4: Test Connection

✓ Bot Connected
Username: @MyClaw_bot
Name: My Claw Assistant
Status: Online

Open your bot in Telegram and send a message!

Bot Configuration

Bot Settings via BotFather

Send these commands to @BotFather:

/setdescription - Bot description shown on profile
/setabouttext - Shown when users view bot info
/setuserpic - Upload bot avatar
/setcommands - Define bot commands menu

Setting Commands

Send /setcommands to BotFather, then:

help - Show available commands
settings - View your settings
clear - Clear conversation history
model - Switch AI model
status - Check system status

Integration Settings

Trigger Modes

ModeBehavior
Always OnRespond to every message
Command OnlyOnly respond to /commands
MentionRespond when @mentioned

Group Settings

Allow Groups: Yes
Allow Channels: Yes
Require Admin for Groups: No
Group Privacy Mode: Disabled (sees all messages)

Privacy Mode

Telegram bots have two privacy modes:

ModeBot Sees
Enabled (default)Only /commands and @mentions
DisabledAll messages in group

To disable privacy mode:

  1. Message @BotFather
  2. Send /setprivacy
  3. Select your bot
  4. Choose Disable

Message Settings

Max Message Length: 4096
Parse Mode: Markdown
Disable Web Preview: No
Disable Notification: No

Markdown Formatting

Your bot can send formatted messages:

*bold***bold**
_italic_*italic*
`code``code`
```code block``` → code block
[link](url) → hyperlink

Inline Mode

Enable inline queries to use your bot in any chat:

  1. Message @BotFather: /setinline
  2. Select your bot
  3. Enter placeholder text: Ask Claw anything...

Now in any chat, type @YourBot_bot your question to get AI responses.

Inline Settings in ClawBook

Inline Mode: Enabled
Inline Cache: 300 seconds
Results per Query: 5
Show Usage Button: Yes

Webhooks vs Polling

Polling (Default)

Bot periodically checks for new messages.

Method: Polling
Interval: 1 second

Pros: Simple, works behind firewalls Cons: Slight delay, more resource usage

Telegram pushes messages to your server instantly.

Method: Webhook
Webhook URL: https://your-domain.com/webhook/telegram

Pros: Instant delivery, lower resource usage Cons: Requires public HTTPS URL

Setting Up Webhooks

  1. Ensure you have a domain with SSL
  2. In ClawBook: IntegrationsTelegramWebhook Settings
  3. Enter your webhook URL
  4. Click Set Webhook

Verify:

curl "https://api.telegram.org/bot<TOKEN>/getWebhookInfo"

Advanced Features

Bot Commands in ClawBook

Define custom commands:

CommandResponse TypeDescription
/startWelcomeGreet new users
/helpStaticShow help text
/clearActionClear history
/settingsInteractiveOpen settings menu

Keyboards

Reply Keyboard

Persistent buttons below chat:

Reply Keyboard:
- ["Help", "Settings"]
- ["Clear History"]
Resize: Yes
One Time: No

Inline Keyboard

Buttons attached to messages:

Inline Keyboard:
- [{"text": "👍 Helpful", "callback": "feedback_good"}]
- [{"text": "👎 Not helpful", "callback": "feedback_bad"}]

Conversation Context

Context Settings:
Max History: 20 messages
Context Window: 24 hours
Per-User Memory: Yes
Group Shared Context: No

Multi-Bot Setup

Run multiple bots with different configurations:

  1. Create additional bots via BotFather
  2. In ClawBook: IntegrationsAdd Telegram Bot
  3. Configure each with different settings:
Bot 1: @GeneralAssistant_bot
- Model: Claude 3.5 Sonnet
- Purpose: General questions

Bot 2: @CodeHelper_bot
- Model: Claude 3.5 Sonnet (code-focused prompt)
- Purpose: Programming help

Bot 3: @QuickAnswers_bot
- Model: Claude 3 Haiku
- Purpose: Fast, simple queries

Troubleshooting

Bot Not Responding

  1. Check bot token is correct
  2. Verify bot isn't blocked
  3. Check ClawBook logs:
    tail -f /var/log/openclaw/telegram.log

"Unauthorized" Error

  • Token may be revoked
  • Generate new token via BotFather
  • Update in ClawBook settings

Messages Delayed

  • Switch from polling to webhooks
  • Check VPS network latency
  • Verify no rate limiting

Bot Kicked from Groups

  • Enable group privacy mode
  • Ensure bot has correct permissions
  • Check for spam-like behavior

Rate Limits

Telegram limits:

  • 30 messages/second to same chat
  • 20 messages/minute to same user in groups

ClawBook auto-handles these limits.

Security

Token Security

  • Never share your bot token
  • Regenerate if compromised via BotFather /revoke
  • Store only in ClawBook's encrypted storage

User Verification

Allowed Users:
- 123456789 # Telegram user IDs
- 987654321

Allow Unknown Users: Yes
Require /start First: Yes

Rate Limiting

Per-User Limits:
Messages per minute: 10
Messages per hour: 100
Cooldown on limit: 60 seconds

Next Steps