-
-
Notifications
You must be signed in to change notification settings - Fork 52.7k
Description
Summary
Heartbeat runs targeting Telegram fail unless TELEGRAM_BOT_TOKEN is set in the gateway environment. The gateway already supports telegram.botToken in clawdbot.json, but the heartbeat send path never passes it through. Gmail hook delivery works because it explicitly resolves the token from config.
Error
Error: TELEGRAM_BOT_TOKEN is required for Telegram sends (Bot API)
Steps to reproduce
- Configure Telegram in
clawdbot.json:telegram.botTokensetagent.heartbeat.target = "telegram"agent.heartbeat.to = "<chat_id>"
- Ensure
TELEGRAM_BOT_TOKENis not set in the environment for the gateway service. - Trigger a heartbeat (wait for interval or manual trigger).
Expected
Heartbeat sends the Telegram message using telegram.botToken from config (or tokenFile/env fallback).
Actual
Heartbeat fails with the error above.
Root Cause
runHeartbeatOnce builds deps.sendTelegram = sendMessageTelegram and calls it without a token:
src/infra/heartbeat-runner.tsusesdeps.sendTelegram(to, chunk, { verbose: false }).src/telegram/send.tsfalls back toopts.token ?? process.env.TELEGRAM_BOT_TOKENand throws when env is missing.
The heartbeat path never calls resolveTelegramToken(cfg).
Contrast (works in hooks/cron)
Cron/hook delivery resolves and passes the token explicitly:
src/cron/isolated-agent.tscallsresolveTelegramToken(params.cfg)and passestokenintosendMessageTelegram.
Suggested Fix
Resolve and pass the Telegram token in the heartbeat path, e.g.:
- Use
resolveTelegramToken(cfg)inrunHeartbeatOnce(ordeliverHeartbeatReply) and passtokenintosendMessageTelegram.
Notes
This looks similar to issue #76 (cron delivery), but the heartbeat code path is separate and still env-only.