Skip to content

Telegram: cron announce sends invalid message_thread_id in private chats #11039

@kdsz001

Description

@kdsz001

Problem

Cron job announce delivery fails with message thread not found error in private chats (non-forum, non-group).

Root Cause

When a cron job runs an isolated session and announces the result back to Telegram:

  1. The announce system resolves the origin from the requester session (main session)
  2. The origin's threadId is populated with a Telegram message ID from the chat context (e.g., 4905)
  3. In sendTelegramMessage() (line ~16797 of reply module), this threadId is passed to buildTelegramThreadParams() with hardcoded scope: "forum":
const threadIdParams = buildTelegramThreadParams(messageThreadId != null ? {
    id: messageThreadId,
    scope: "forum"  // Always "forum", even for private chats!
} : void 0);
  1. Telegram API rejects message_thread_id in private chats → 400: Bad Request: message thread not found

Expected Behavior

  • Private chat messages should NOT include message_thread_id
  • The scope should reflect the actual chat type, not be hardcoded to "forum"

Affected Features

  • All cron jobs with delivery.mode: "announce" and delivery.channel: "telegram" fail to deliver results
  • The isolated sessions run successfully, but users never receive the announcement

Workaround

None found yet. Restarting gateway does not clear the cached origin threadId.

Environment

  • OpenClaw 2026.2.6
  • Telegram private chat (not a forum/group)
  • Cron jobs with isolated sessions + announce delivery

Reproduction

  1. Set up OpenClaw with Telegram private chat (DM)
  2. Create a cron job with sessionTarget: "isolated" and delivery: {mode: "announce", channel: "telegram"}
  3. Wait for the job to run
  4. Observe error: GrammyError: Call to 'sendMessage' failed! (400: Bad Request: message thread not found)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions