Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@azade-c
Copy link
Contributor

@azade-c azade-c commented Jan 13, 2026

Problem

In Telegram forum groups, the General topic uses thread_id=1. The Telegram Bot API has inconsistent behavior for this topic:

  • sendMessage with message_thread_id=1 → ❌ Rejected ("message thread not found")
  • sendChatAction (typing) without message_thread_id → ❌ No typing shown

After the channels rename refactor, Clawdbot started explicitly sending message_thread_id=1 for messages in the General topic, triggering this error:

GrammyError: Call to 'sendMessage' failed! (400: Bad Request: message thread not found)

Investigation

We tested the Telegram Bot API behavior for the General topic:

API Call Without thread_id With thread_id=1
sendMessage ✅ Routes to General ❌ Error: thread not found
sendChatAction ❌ No typing shown ✅ Typing appears

This is an inconsistency in the Telegram Bot API — it requires opposite handling for messages vs typing indicators.

Solution

Refactored thread handling into two distinct functions to work around the API inconsistency:

buildTelegramThreadParams()

For sending messages. Omits message_thread_id for General topic (1) — Telegram routes automatically.

buildTypingActionParams()

For typing indicators (sendChatAction). Includes message_thread_id=1 — required by the API for typing to appear.

Testing

Tested in a Telegram forum group:

  • ✅ Messages delivered successfully to General
  • ✅ Typing indicator appears in General
  • ✅ Messages and typing work in other topics

@azade-c azade-c force-pushed the fix/telegram-general-topic-messages branch 3 times, most recently from 773476e to 3821d47 Compare January 13, 2026 13:49
Copy link
Contributor

@erik-agens erik-agens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me and solves an issue that takes a bit of time to debug.
👍

@azade-c
Copy link
Contributor Author

azade-c commented Jan 14, 2026

Update after upstream refactor

The original fix was lost during the refactor(telegram): split bot handlers changes. I've re-applied the fix with a cleaner approach:

  • Added buildTypingActionParams() in helpers.ts that excludes message_thread_id for General topic (1)
  • Telegram doesn't display typing indicators correctly when thread_id is explicitly set to 1

Force-pushed to align with current upstream main.

@azade-c azade-c force-pushed the fix/telegram-general-topic-messages branch from abfa3a7 to fec4ad7 Compare January 15, 2026 14:23
@azade-c azade-c marked this pull request as draft January 15, 2026 14:25
@azade-c azade-c force-pushed the fix/telegram-general-topic-messages branch 3 times, most recently from ad86b93 to 9b44cef Compare January 15, 2026 23:26
@azade-c azade-c marked this pull request as ready for review January 15, 2026 23:26
@azade-c
Copy link
Contributor Author

azade-c commented Jan 15, 2026

Correction: My previous comment was incorrect.

The actual behavior:

  • Messages (sendMessage): EXCLUDE message_thread_id=1 for General topic — Telegram API rejects it
  • Typing (sendChatAction): INCLUDE message_thread_id=1 for General topic — required for typing to show

Two helper functions:

  • buildTelegramThreadParams(): excludes General topic (for messages)
  • buildTypingThreadParams(): includes General topic (for typing)

Telegram General topic (id=1) has inconsistent API behavior:
- sendMessage: rejects explicit message_thread_id=1
- sendChatAction: requires message_thread_id=1 for typing to show

Split into two helper functions:
- buildTelegramThreadParams: excludes General topic for messages
- buildTypingThreadParams: includes General topic for typing
@azade-c azade-c force-pushed the fix/telegram-general-topic-messages branch from 9b44cef to 6146acb Compare January 15, 2026 23:32
@steipete steipete self-assigned this Jan 15, 2026
@steipete steipete merged commit fe8b28c into openclaw:main Jan 16, 2026
17 of 22 checks passed
@steipete
Copy link
Contributor

Landed via temp rebase onto main; follow-up cherry-pick applied after merge (PR head did not include the updated commit).

Thanks @azade-c!

@azade-c azade-c deleted the fix/telegram-general-topic-messages branch January 16, 2026 00:17
cpojer pushed a commit to cpojer/clawdbot that referenced this pull request Jan 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants