From 2f9306b98ad39db614197e72e9d173083cd375fb Mon Sep 17 00:00:00 2001 From: Yurii Chukhlib Date: Thu, 8 Jan 2026 20:40:00 +0100 Subject: [PATCH] fix(heartbeat): pass accountId for Telegram delivery Heartbeat Telegram delivery was failing when the bot token was configured only via telegram.botToken in config (without TELEGRAM_BOT_TOKEN environment variable). Root cause: deliverOutboundPayloads was called without accountId parameter, so sendMessageTelegram couldn't determine which account to use and couldn't find the token from config. Fix: Resolve default Telegram accountId when provider is "telegram" and pass it to deliverOutboundPayloads. This follows the same pattern used elsewhere in the codebase (e.g., cron uses resolveTelegramToken). Changes: - Added import for resolveDefaultTelegramAccountId - Added accountId resolution for telegram provider - Updated deliverOutboundPayloads call to include accountId Fixes #318 Co-Authored-By: Claude --- src/infra/heartbeat-runner.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/infra/heartbeat-runner.ts b/src/infra/heartbeat-runner.ts index b015a0896..25b5aab8e 100644 --- a/src/infra/heartbeat-runner.ts +++ b/src/infra/heartbeat-runner.ts @@ -22,6 +22,7 @@ import { createSubsystemLogger } from "../logging.js"; import { getQueueSize } from "../process/command-queue.js"; import { webAuthExists } from "../providers/web/index.js"; import { defaultRuntime, type RuntimeEnv } from "../runtime.js"; +import { resolveDefaultTelegramAccountId } from "../telegram/accounts.js"; import { getActiveWebListener } from "../web/active-listener.js"; import { emitHeartbeatEvent } from "./heartbeat-events.js"; import { @@ -315,10 +316,17 @@ export async function runHeartbeatOnce(opts: { } } + // Resolve accountId for providers that support multiple accounts + const accountId = + delivery.provider === "telegram" + ? resolveDefaultTelegramAccountId(cfg) + : undefined; + await deliverOutboundPayloads({ cfg, provider: delivery.provider, to: delivery.to, + accountId, payloads: [ { text: normalized.text,