Skip to content

MS Teams: add user mention support#15436

Merged
steipete merged 4 commits intoopenclaw:mainfrom
hyojin:feature/msteams-mention
Feb 13, 2026
Merged

MS Teams: add user mention support#15436
steipete merged 4 commits intoopenclaw:mainfrom
hyojin:feature/msteams-mention

Conversation

@hyojin
Copy link
Contributor

@hyojin hyojin commented Feb 13, 2026

MS Teams: add user mention support

What

Adds support for @mentions in Microsoft Teams channel, enabling:

  • Parse mention entities from Teams messages
  • Validate mention IDs to prevent false positives from code snippets
  • Proper whitespace handling for mention text
  • Documentation for User.Read.All permission requirement

Why

Enables OpenClaw to properly handle @mentions in Teams conversations, improving interaction quality and allowing dynamic user search.

Changes

  • New: extensions/msteams/src/mentions.ts - Core mention parsing and validation logic
  • New: extensions/msteams/src/mentions.test.ts - Comprehensive test suite (17 tests)
  • Modified: extensions/msteams/src/messenger.ts - Integration with message handling
  • Docs: docs/channels/msteams.md - Added User.Read.All permission documentation

Testing

  • ✅ 17 unit tests passing
  • ✅ Build successful
  • ✅ Lint/format checks passed
  • ✅ Integration tested with MS Teams messenger

AI-Assisted Development

  • Tool: Claude (Sonnet)
  • Testing: Fully tested with comprehensive unit test coverage
  • Verification: All code reviewed and understood

Notes

  • User mentions work out of the box for conversation participants
  • User.Read.All permission only needed for searching users not in the current conversation
  • Fake placeholders used in tests to protect privacy

Greptile Overview

Greptile Summary

Adds outbound Microsoft Teams user-mention support by introducing a mention parser (extensions/msteams/src/mentions.ts) that converts @[Name](id) markup into Teams <at>Name</at> tags plus entities payloads, and wiring it into message sending (extensions/msteams/src/messenger.ts). Includes a new vitest suite covering mention parsing/validation cases and updates MS Teams docs to note the User.Read.All permission requirement for mentioning users outside the current conversation.

Confidence Score: 4/5

  • This PR is close to mergeable but has a concrete edge case that can cause runtime failures in mention formatting.
  • The integration point in messenger.ts is straightforward (only adds entities when present) and the new parsing logic is covered by tests, but formatMentionText constructs regexes from unescaped user display names, which can throw or replace unintended text for names containing regex metacharacters.
  • extensions/msteams/src/mentions.ts

Last reviewed commit: b781104

(2/5) Greptile learns from your feedback when you react with thumbs up/down!

@openclaw-barnacle openclaw-barnacle bot added docs Improvements or additions to documentation channel: msteams Channel integration: msteams size: M labels Feb 13, 2026
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

4 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment on lines 109 to 111
const namePattern = new RegExp(`@${mention.name}`, "gi");
formatted = formatted.replace(namePattern, `<at>${mention.name}</at>`);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Regex injection in mentions

formatMentionText builds a RegExp directly from mention.name (new RegExp(@${mention.name}, "gi")). If a display name contains regex metacharacters (e.g. (, +, ., ?, [), this will either throw at runtime (invalid regex) or match/replace unintended parts of the message. Escape mention.name before constructing the regex (or avoid regex entirely by using a safer search/replace strategy).

Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/msteams/src/mentions.ts
Line: 109:111

Comment:
**Regex injection in mentions**

`formatMentionText` builds a `RegExp` directly from `mention.name` (`new RegExp(`@${mention.name}`, "gi")`). If a display name contains regex metacharacters (e.g. `(`, `+`, `.`, `?`, `[`), this will either throw at runtime (invalid regex) or match/replace unintended parts of the message. Escape `mention.name` before constructing the regex (or avoid regex entirely by using a safer search/replace strategy).

How can I resolve this? If you propose a fix, please make it concise.

@steipete steipete self-assigned this Feb 13, 2026
hyojin and others added 4 commits February 13, 2026 15:09
- Add mention parsing and validation logic
- Handle mention entities with proper whitespace
- Validate mention IDs to prevent false positives from code snippets
- Use fake placeholders in tests for privacy
Clarify that User.Read.All permission is only needed for searching
users not in the current conversation. Mentions work out of the box
for conversation participants.
Escape regex metacharacters in display names before constructing RegExp
to prevent runtime errors or unintended matches when names contain special
characters like (, ), ., +, ?, [, etc.

Add test coverage for names with regex metacharacters.
@steipete steipete force-pushed the feature/msteams-mention branch from efba549 to 460fbde Compare February 13, 2026 14:10
@steipete steipete merged commit 106d605 into openclaw:main Feb 13, 2026
3 checks passed
@steipete
Copy link
Contributor

Landed via temp rebase onto main.

  • Gate: pnpm lint && pnpm build && pnpm test
  • Land commit: 460fbde
  • Merge commit: 106d605

Thanks @hyojin!

alex-muradov pushed a commit to alex-muradov/openclaw that referenced this pull request Feb 13, 2026
zhangyang-crazy-one pushed a commit to zhangyang-crazy-one/openclaw that referenced this pull request Feb 13, 2026
skyhawk14 pushed a commit to skyhawk14/openclaw that referenced this pull request Feb 13, 2026
steipete added a commit to azade-c/openclaw that referenced this pull request Feb 14, 2026
GwonHyeok pushed a commit to learners-superpumped/openclaw that referenced this pull request Feb 15, 2026
cloud-neutral pushed a commit to cloud-neutral-toolkit/openclawbot.svc.plus that referenced this pull request Feb 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: msteams Channel integration: msteams docs Improvements or additions to documentation size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments