Skip to content

fix(msteams): detect implicit mentions in thread replies via conversation.id#261

Open
BingqingLyu wants to merge 4 commits intomainfrom
fork-pr-41108-fix-implicit-mention-thread-root-fallback
Open

fix(msteams): detect implicit mentions in thread replies via conversation.id#261
BingqingLyu wants to merge 4 commits intomainfrom
fork-pr-41108-fix-implicit-mention-thread-root-fallback

Conversation

@BingqingLyu
Copy link
Copy Markdown
Owner

@BingqingLyu BingqingLyu commented Apr 27, 2026

Summary

Fixes thread reply implicit mention detection for MS Teams. When requireMention: true, replying to a bot message in a thread without @mention now correctly bypasses the mention gate.

Two changes:

  1. Fallback to conversation.id;messageid= for implicit mention — Teams doesn't reliably send replyToId, but it does encode the thread root message ID in conversation.id. The existing extractMSTeamsConversationMessageId() function already parses this; now it's wired into the implicit mention check.

  2. Cache thread root ID on send — The conversation.id;messageid= points to the thread root (the user's original message), not the bot's reply. So we also record the thread root ID in the sent-message cache when the bot replies, enabling the lookup to succeed.

Important: RSC required

This fix also requires ChannelMessage.Read.Group RSC permission in the Teams app manifest. Without RSC, Teams doesn't deliver thread replies to the bot webhook at all — the messages never reach OpenClaw. This is a Teams platform limitation documented in MicrosoftDocs/msteams-docs#4530.

Test plan

  • 8 new unit tests for implicit mention fallback logic (all pass)
  • 4 new unit tests for extractMSTeamsConversationMessageId (all pass)
  • Verified in production with RSC enabled:
    • @mention → responded ✅
    • Thread reply without @mention → responded (implicit mention) ✅
    • Multiple thread replies → all responded ✅
    • Top-level message without @mention → correctly ignored ✅

Closes openclaw#38629

🤖 Generated with Claude Code

vongohren and others added 4 commits March 7, 2026 07:10
Teams doesn't reliably send replyToId in thread replies. Fall back to
the thread root message ID extracted from conversation.id (the
;messageid=XXX suffix) when checking if the bot sent a message in that
thread.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…lies

The previous commit added conversation.id;messageid= as a fallback for
implicit mention detection, but the lookup still failed because the
sent-message cache only contained the bot's reply IDs, not the thread
root ID that Teams puts in conversation.id.

This commit also records the thread root message ID (conversationMessageId)
when the bot sends a reply, so subsequent thread replies match correctly.

Note: This fix requires ChannelMessage.Read.Group RSC permission in the
Teams app manifest for thread replies to reach the bot at all.

Tested and verified in production.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Extract the implicit mention computation from message-handler.ts into a
dedicated implicit-mention.ts module. Both the production code and the
tests now import the same function, so regressions in the logic will be
caught by the test suite.

Addresses review feedback about test helper duplicating production logic.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

[Bug]: msteams implicit mention fails — replyToId unreliable, conversation.id threadRootId not used as fallback

2 participants