Integration8 min read
Telegram Integration with OpenClaw: Complete Setup Guide
Connect your OpenClaw app to Telegram for notifications, bot commands, and real-time alerts. Full setup in 10 minutes.
Telegram integration is one of the most popular OpenClaw features. Get deploy notifications, error alerts, and interactive bot commands — all in your Telegram app.
Why Telegram?
- Instant — notifications arrive in seconds
- Reliable — 99.9%+ uptime
- Free — no cost for bot API
- Powerful — rich messages, inline keyboards, groups
Step 1: Create a Telegram Bot
- Open Telegram and search for @BotFather
- Send
/newbot - Give it a name and username
- Copy the bot token (looks like
123456789:ABCdef...)
Step 2: Set the Token in OpenClaw
openclaw env set TELEGRAM_BOT_TOKEN="123456789:ABCdef..."
Step 3: Configure Notifications
In your app, use the OpenClaw Telegram SDK:
import { telegram } from '@openclaw/telegram'
// Send a message
await telegram.send({
chat_id: process.env.TELEGRAM_CHAT_ID,
message: `✅ Deploy successful: ${app.name} is live`
})
// Send with options
await telegram.send({
chat_id: process.env.TELEGRAM_CHAT_ID,
message: `❌ Error detected`,
options: {
parse_mode: 'HTML',
reply_markup: {
inline_keyboard: [
[{ text: 'View Logs', url: 'https://openclaw.dev/logs' }]
]
}
}
})
Step 4: Get Your Chat ID
Send a message to your bot in Telegram, then:
curl https://api.telegram.org/bot<YOUR_TOKEN>/getUpdates
Look for "chat":{"id":123456789,...} in the response. That's your chat ID.
Set it:
openclaw env set TELEGRAM_CHAT_ID="123456789"
Common Use Cases
Deploy Notifications
// In your CI/CD pipeline
await telegram.send({
chat_id: process.env.TELEGRAM_CHAT_ID,
message: `🚀 <b>${process.env.APP_NAME}</b> deployed\nVersion: ${gitSha}\nBy: ${gitAuthor}`
})
Error Alerts
// In your error handler
app.use((err, req, res, next) => {
telegram.send({
chat_id: process.env.TELEGRAM_CHAT_ID,
message: `🚨 <b>Error in ${req.path}</b>\n${err.message}`
})
next(err)
})
Health Check Failures
OpenClaw can auto-alert you when health checks fail:
openclaw alerts set --type health --telegram --threshold 3
Group Notifications
For team notifications, create a group and add the bot. Use the group's chat ID (it's negative, like -123456789).
Security Tips
- Never commit your bot token to git
- Use environment variables, not hardcoded values
- Consider a separate bot per environment (prod vs staging)