improvement(ms-teams): resolve mentions accurately#1762
Merged
icecrasher321 merged 9 commits intostagingfrom Oct 30, 2025
Merged
improvement(ms-teams): resolve mentions accurately#1762icecrasher321 merged 9 commits intostagingfrom
icecrasher321 merged 9 commits intostagingfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Greptile Overview
Greptile Summary
This PR adds proper mention resolution for MS Teams chat and channel messages. When users include <at>name</at> tags in messages, the system now fetches member lists from the MS Graph API, matches names to user IDs, and properly formats mentions in the message payload.
Key changes:
- Added
parseMentions(),fetchChatMembers(),fetchChannelMembers(), andresolveMentionsForChat/Channel()utility functions - Updated tool configuration to detect mentions via regex and route to custom API when found
- Modified API routes to call mention resolution, build proper mention entities, and set contentType to 'html' when mentions are present
- Implemented graceful error handling that continues without mentions if resolution fails
- Improved TypeScript typing by replacing
anycasts with proper type definitions for message bodies
Confidence Score: 5/5
- This PR is safe to merge with minimal risk
- The implementation follows best practices with proper error handling, TypeScript typing, and graceful degradation. The mention resolution is wrapped in try-catch blocks that log warnings but continue execution if it fails. The regex pattern for detecting mentions is straightforward and the member matching logic uses simple case-insensitive string comparison. No security vulnerabilities or logic errors were identified.
- No files require special attention
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| apps/sim/tools/microsoft_teams/utils.ts | 5/5 | Added mention resolution utilities including parseMentions, fetchChatMembers, fetchChannelMembers, and resolveMentions functions |
| apps/sim/app/api/tools/microsoft_teams/write_channel/route.ts | 5/5 | Integrated mention resolution with proper error handling and contentType management |
| apps/sim/app/api/tools/microsoft_teams/write_chat/route.ts | 5/5 | Integrated mention resolution with proper error handling and contentType management |
Sequence Diagram
sequenceDiagram
participant Client
participant ToolConfig as write_chat/write_channel
participant API as Custom API Route
participant Utils as Utils (resolveMentions)
participant MSGraph as Microsoft Graph API
Client->>ToolConfig: Send message with <at>name</at>
ToolConfig->>ToolConfig: Detect mentions with regex
alt Has mentions or files
ToolConfig->>API: Route to custom API
API->>API: Parse and validate request
API->>Utils: Call resolveMentionsForChat/Channel
Utils->>Utils: parseMentions(content)
Utils->>MSGraph: Fetch chat/channel members
MSGraph-->>Utils: Return member list
Utils->>Utils: Match mention names to member IDs
Utils-->>API: Return mention entities
API->>API: Set contentType to 'html'
API->>API: Build messageBody with mentions
API->>MSGraph: POST message with mentions array
MSGraph-->>API: Message created
API-->>Client: Success response
else No mentions and no files
ToolConfig->>MSGraph: Direct API call
MSGraph-->>Client: Message created
end
5 files reviewed, no comments
This reverts commit 0ac702a.
10 tasks
waleedlatif1
pushed a commit
that referenced
this pull request
Nov 12, 2025
* improvement(ms-teams): resolve mentions accurately * fix for bots * add utils file * add logs * fix perms issue * fix scopes * fetch works for bots * Revert "fetch works for bots" This reverts commit 0ac702a. * update docs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolve @ mentions correctly for MS-teams write chat and write channel tools for users.
Type of Change
Testing
Testing with @aadamgough
Checklist