Skip to content

fix(channels) : route Telegram replies to the correct forum topic - #7610

Closed
tranvantruonggit wants to merge 1 commit into
QwenLM:mainfrom
tranvantruonggit:fix/telegram-topic-routing
Closed

fix(channels) : route Telegram replies to the correct forum topic#7610
tranvantruonggit wants to merge 1 commit into
QwenLM:mainfrom
tranvantruonggit:fix/telegram-topic-routing

Conversation

@tranvantruonggit

@tranvantruonggit tranvantruonggit commented Jul 23, 2026

Copy link
Copy Markdown

What this PR does

Routes Telegram bot replies back to the same forum topic the user messaged from, instead of always landing in #general. Does this by caching the threadId from inbound envelopes and passing it through sendMessage to sendTelegramMessage.

Why it's needed

When a Qwen Code Telegram bot is used in a supergroup with Topics enabled, all bot replies appear in #general regardless of which topic the user messaged from. sessionScope: "thread" creates isolated sessions per topic, but outbound replies don't route back to the correct thread.

Closes #7609

Reviewer Test Plan

  1. Create a Telegram supergroup with Topics enabled
  2. Add the bot to the group
  3. Send a message in a specific topic (not #general)
  4. Before fix: bot reply appears in #general
  5. After fix: bot reply appears in the same topic the user messaged from

Risk & Scope

  • Risk: Low. The change is local to TelegramChannel — it adds a chatId → threadId cache populated from inbound message handlers. If threadId is not in the cache (e.g. DM, non-topic group, or first message), sendTelegramMessage receives undefined and behaves exactly as before.
  • Out of scope: Typing indicators still go to #general (they don't go through sendMessage). This can be addressed separately if needed.

Linked Issues

Closes #7609

sendMessage() now looks up the cached threadId from chatThreadMap
(populated from inbound envelopes) and passes it to sendTelegramMessage,
so bot replies appear in the same Telegram forum topic the user messaged
from instead of always landing in #general.

Closes QwenLM#7609

@qwen-code-ci-bot qwen-code-ci-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@tranvantruonggit Thanks for the fix — the approach looks right at a glance, but the PR body is empty (just Closes #7609). The PR template requires a few sections so reviewers can evaluate the change without digging through the issue thread:

  • What this PR does — one or two sentences on the change
  • Why it's needed — link the issue and summarize the problem
  • Reviewer Test Plan — how to verify (steps, expected vs. observed behavior)
  • Risk & Scope — main risk, what's out of scope
  • Linked IssuesCloses #7609 (already there, just needs the heading)

Could you fill those in? Once the template is complete we can move straight to code review.

中文说明

@tranvantruonggit 感谢提交修复——方案看起来是对的,但 PR 描述目前是空的(只有 Closes #7609)。PR 模板要求填写以下几个部分,方便 reviewer 快速评估:

  • What this PR does — 一两句话描述改动
  • Why it's needed — 关联 issue,说明问题背景
  • Reviewer Test Plan — 如何验证(步骤、预期 vs 实际行为)
  • Risk & Scope — 主要风险、不在范围内的内容
  • Linked IssuesCloses #7609(已有,加上标题即可)

麻烦补充一下,模板完整后我们直接进入代码审查。

Qwen Code · qwen3.8-max-preview

@tranvantruonggit

Copy link
Copy Markdown
Author

I updated the PR

@tranvantruonggit

Copy link
Copy Markdown
Author

"Superseded by the more comprehensive #7612"

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.

fix(channels): Telegram replies always go to #general instead of the topic thread

2 participants