Skip to content

fix(telegram): 403 'bot was kicked' error is misleading when posting to a locked forum topic #29048

@bboyyan

Description

@bboyyan

Summary

When a cron job is configured to deliver to a Telegram Forum topic that restricts posting (e.g. topic:1 / General), the bot receives a 403: Forbidden: bot was kicked from the supergroup chat error. This message is identical to the error when the bot is actually removed from the group, making root cause analysis extremely difficult.

Steps to Reproduce

  1. Create a Telegram Forum group (with Topics enabled)
  2. Configure a cron job with delivery.to = "<chatId>:topic:1" (General topic)
  3. Ensure the General topic has posting restricted to admins only (Telegram default)
  4. Trigger the cron job

Actual Behaviour

403: Forbidden: bot was kicked from the supergroup chat
lastError: "cron announce delivery failed"

The bot is still a member of the group and responds normally to direct messages. Only cron delivery fails.

Expected Behaviour

The error message should distinguish between:

  • Bot actually removed from the group
  • Bot lacks permission to post in a specific topic

Suggested: when delivery.to contains :topic:, append a hint such as:

"Bot may lack permission to post in this topic. Check if the topic restricts posting to admins only."

Root Cause

Telegram's Bot API returns the same 403: Forbidden: bot was kicked from the supergroup chat for both scenarios:

  1. Bot removed from the group
  2. Bot attempting to post in a topic where it lacks can_post_messages permission (e.g. General topic with admin-only posting)

OpenClaw correctly treats this as a permanent error (no retry), but the error message leads users — and agents — to investigate the wrong direction (re-adding the bot, checking tokens, etc.).

Impact

  • PERMANENT_ANNOUNCE_DELIVERY_ERROR_PATTERNS and PERMANENT_ERROR_PATTERNS in delivery-queue.ts both match on /forbidden: bot was kicked/i, which is correct behaviour for retries — but the surfaced error message is misleading
  • Users spend significant time re-adding the bot, checking tokens, and reviewing unrelated code paths
  • Agents investigating the error also follow the wrong diagnosis path

Suggested Fix

When the resolved delivery target contains a threadId (i.e. a forum topic), supplement the 403 error message:

403: Forbidden: bot was kicked from the supergroup chat
Hint: target includes a forum topic (:topic:1). This error may indicate the topic restricts posting to admins only, not that the bot was removed from the group. Try changing the topic ID or granting the bot posting rights in that topic.

Alternatively, detect and distinguish the two cases if Telegram ever returns different error strings for them.

Workaround

Change delivery.to from topic:1 (General) to a non-restricted topic ID. General topic (topic:1) in Telegram Forum groups defaults to admin-only posting.

Environment

  • OpenClaw 2026.2.23
  • Telegram channel, forum group with Topics enabled
  • Cron job with sessionTarget: "isolated", wakeMode: "now", delivery.mode: "announce"

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleMarked as stale due to inactivity

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions