#8985: fix(telegram): preserve forum topic context for pairing auto-replies
channel: telegram
stale
Cluster:
Messaging Platform Improvements
## Summary
When a new user sends a message in a Telegram forum topic, the pairing auto-reply was being sent to the General channel instead of the original topic.
## Root Cause
In `bot-message-context.ts`, the `bot.api.sendMessage` call for pairing replies did not pass `message_thread_id`, causing the reply to go to the root of the forum group.
## Fix
Pass `message_thread_id` to `sendMessage` when sending pairing replies:
```typescript
bot.api.sendMessage(
chatId,
pairingMessage,
messageThreadId ? { message_thread_id: messageThreadId } : undefined,
)
```
## Testing
- Code review: `messageThreadId` is already extracted from the incoming message at line 159
- Lint passes
- This is a minimal, low-risk change (1 line addition)
Fixes #8820
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This change updates the Telegram DM pairing auto-reply path to include `message_thread_id` when replying, so that if the inbound message originated from a forum topic the pairing response is posted back into the same topic instead of the forum’s root/General channel.
The update is localized to the `dmPolicy === "pairing"` unauthorized-sender branch in `src/telegram/bot-message-context.ts`, and it mirrors the existing thread-awareness patterns elsewhere in this file (e.g., typing actions using `buildTypingThreadParams(replyThreadId)`).
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk.
- The change is a small, targeted parameter addition to a single Telegram API call and aligns with Telegram forum semantics; no broader behavior changes were introduced in the commit diff.
- No files require special attention
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#19213: Telegram: preserve DM topic thread in direct replies
by Kemalau · 2026-02-17
85.8%
#7911: Unapproved users receive pairing codes on every /start message befo...
by crazypeace · 2026-02-03
83.6%
#14443: fix(telegram): skip General topic thread ID for all chat types (#14...
by lailoo · 2026-02-12
82.9%
#7261: fix(telegram): preserve DM topic thread id for outbound media
by ViffyGwaanl · 2026-02-02
82.4%
#17952: fix(telegram): support message_thread_id for DM topics
by timbrinded · 2026-02-16
81.9%
#17968: fix(telegram): restore DM topic thread ids with send-path fallback
by Leonccaa · 2026-02-16
81.5%
#6192: Telegram: fix DM Topics thread routing
by ViffyGwaanl · 2026-02-01
80.9%
#12936: fix(telegram): omit message_thread_id for private DM chats
by omair445 · 2026-02-09
80.6%
#6457: fix(telegram): register commands for group scope + preserve topic t...
by dae-sun · 2026-02-01
78.9%
#3368: fix: sessions navigation, DM thread display, and DM thread delivery...
by Lukavyi · 2026-01-28
78.6%