Files
345f63b099 fix(telegram): a chat that stops receiving is an alert, and a picture never vanishes silently (#1765)
* fix(telegram): a chat that stops receiving is an alert, and a picture never vanishes silently

On 2026-11-23 a screenshot of an event sent on Telegram reached nothing: no
agent turn, no booking, no alert, no error. The owner's chat bot is collected
by the OpenClaw gateway (long polling), and the only health check asked
whether the gateway answered HTTP, which it can do while its Telegram channel
collects nothing.

- check-gateway also asks Telegram for the chat bot's inbox (getWebhookInfo,
  read-only, lib/telegram/inbox.ts): a webhook set on the polled bot, or
  updates waiting on two ticks in a row, raises telegram_inbox_stuck once and
  says so in the chat (outbound still works when inbound is dead); it clears
  on recovery. Skipped while the gateway itself is down.
- Loki's notification bot can no longer take over the chat bot: the same
  token in TELEGRAM_NOTIFY_BOT_TOKEN is ignored (env.ts warns), since its
  setWebhook would cut the gateway off from every owner message.
- ensureWebhook re-registers when Telegram reports 401/403 (a rotated
  AUTH_SECRET left the URL matching and every update refused), keeping the
  queued updates; the route logs refused calls (throttled).
- A photo or image file sent to the notification bot gets a reply saying it
  was not read or booked and where to send it, and is recorded; a failed
  reply is logged instead of swallowed.

Test: scripts/test/telegram-inbound.ts with a Telegram photo-update fixture.

Co-Authored-By: Claude <noreply@anthropic.com>

* docs(telegram): register the chat-bot inbox probe (src/lib/telegram/inbox.ts)

check-telegram-registry failed on #1765: inbox.ts calls api.telegram.org
but had no row in docs/telegram-notifications.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmvb6xi489TfZMg7n9T

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: catomean <catomean@users.noreply.github.com>
2026-11-23 20:54:54 +01:00
..