Get Telegram Bot Downtime Notifications Before Your Users Do
The worst way to find out your bot is down is a message from a user. Here are three approaches to get notified of downtime instantly โ from a 10-minute DIY script to a fully automated repair system that fixes it before you even know it happened.
Why default OpenClaw monitoring isn't enough
OpenClaw logs events, but it doesn't alert you when the gateway goes down. The gateway process doesn't know to send you a message โ because it's the thing that sends messages, and it's dead.
You need something external to the gateway watching it. Here are three options in order of complexity:
Method 1: Self-pinging cron alert
A cron job runs every few minutes, checks if the gateway is alive, and sends you a Telegram message if it's not. You need a second bot token to send the alert (can't use the down bot to tell you it's down).
#!/bin/bash
# Get these from @BotFather (alert bot, separate from your main bot)
ALERT_TOKEN="123456:your-alert-bot-token"
ALERT_CHAT="987654321" # Your personal Telegram chat ID (get from @userinfobot)
if ! pgrep -f "openclaw-gateway" > /dev/null 2>&1; then
MSG="โ ๏ธ *OpenClaw bot is down* โ $(hostname) โ $(date '+%H:%M UTC')"
curl -s -X POST "https://api.telegram.org/bot${ALERT_TOKEN}/sendMessage" \
-d "chat_id=${ALERT_CHAT}" \
-d "text=${MSG}" \
-d "parse_mode=Markdown" > /dev/null
fi*/5 * * * * /usr/local/bin/openclaw-alert.sh
- Free
- No dependencies
- 10 minutes to set up
- 5 minute detection lag
- Alert only โ no repair
- You still need to fix it
Method 2: Health endpoint + external monitor
If your OpenClaw bot exposes an HTTP health endpoint, external services like UptimeRobot (free) or Better Uptime ($7/mo) can monitor it every minute and alert you via Telegram, email, or SMS.
Add a health endpoint to your OpenClaw workspace
Add this to your OpenClaw config or a companion Express server:
// Companion health server for OpenClaw
const http = require('http');
const { execSync } = require('child_process');
const server = http.createServer((req, res) => {
if (req.url === '/health') {
try {
// Check if gateway process is running
const pid = execSync('pgrep -f openclaw-gateway').toString().trim();
res.writeHead(200, {'Content-Type': 'application/json'});
res.end(JSON.stringify({ ok: true, pid }));
} catch {
res.writeHead(503, {'Content-Type': 'application/json'});
res.end(JSON.stringify({ ok: false, error: 'gateway not running' }));
}
} else {
res.writeHead(404); res.end();
}
});
server.listen(8080, '127.0.0.1', () => {
console.log('Health server on http://localhost:8080/health');
});Then monitor https://your-server.com/health in UptimeRobot. When it returns non-200, you get alerted.
- 1-minute detection
- Free tier available
- Email + SMS + Telegram
- Still manual repair
- Extra server to maintain
- False positives if server slow
Method 3: Mechanic Bot โ alert + auto-repair
The above approaches tell you the bot is down. You still have to fix it. Mechanic Bot does both: detects within 60 seconds, attempts auto-repair, and then notifies you โ with the outcome already included.
What the notification looks like:
โ Fixed in 47s โ MyBot is back online Your bot went offline at 02:14 UTC. Mechanic detected and repaired it automatically. What happened: Config file had a syntax error What was done: Backup โ deep-merge repair โ restart Method: config_check_restart (attempt 1 of 5) โ View repair details
You get this message instead of the alert that woke you up. The repair already happened.
Setup (4 minutes)
curl -fsSL https://mechanicbot.io/onboard.sh | sudo bash -s -- \ --token YOUR_INSTALL_TOKEN \ --email you@example.com
After install, link your Telegram in the dashboard to receive repair notifications in your personal Telegram chat.
- Fixes it before you reply
- 60-second detection
- Handles config corruption
- Audit trail of every repair
- $9/mo (vs. free cron)
- Requires install on server
Which approach should you use?
It depends on how much the downtime costs you:
- Hobby bot, few users: Method 1 (free cron) is fine. 5-minute lag is acceptable.
- Bot with paying/active users: Method 2 gives you 1-minute detection. Still manual repair, but you know fast.
- Bot running for clients / business: Method 3. Downtime costs more than $9/mo in reputation + time to fix.
If you'd be embarrassed by 2 hours of undetected downtime, you need automated repair โ not just alerts.
Get alerted when it's already fixed.
Mechanic Bot monitors your OpenClaw bot 24/7. When it goes down, Mechanic fixes it and sends you a notification with the outcome โ not a wake-up call.
Start 14-day free trial โ Bot down right now?