-
-
Notifications
You must be signed in to change notification settings - Fork 52.8k
Description
Summary
Isolated cron jobs with channel: "telegram" fail to deliver messages even though telegram.botToken is set in ~/.clawdis/clawdis.json. The agent runs successfully and generates output, but delivery fails.
Error
Error: TELEGRAM_BOT_TOKEN is required for Telegram sends (Bot API)
Root Cause
In src/cron/isolated-agent.ts, the sendMessageTelegram calls don't pass the token from config:
// Line 352 - missing token
await params.deps.sendMessageTelegram(chatId, chunk, {
verbose: false,
});The sendMessageTelegram function in src/telegram/send.ts falls back to process.env.TELEGRAM_BOT_TOKEN when no explicit token is passed, but the gateway process (especially when started from the macOS app) doesn't have this env var set.
This is inconsistent with the gateway startup code which correctly reads from config:
// server.ts line 1894-1895
const telegramToken = process.env.TELEGRAM_BOT_TOKEN ?? cfg.telegram?.botToken ?? "";Fix
Pass the config token to both sendMessageTelegram calls in isolated-agent.ts:
await params.deps.sendMessageTelegram(chatId, chunk, {
verbose: false,
token: params.cfg.telegram?.botToken,
});Same fix needed for the media URL variant around line 361.
Affected
Cron jobs with sessionTarget: "isolated" + channel: "telegram" + deliver: true