-
Notifications
You must be signed in to change notification settings - Fork 12
Add support for Targeted Messages #241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add support for Targeted Messages #241
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces support for targeted messages in Microsoft Teams, allowing messages to be sent privately to specific recipients within a conversation. The implementation adds an is_targeted boolean parameter throughout the messaging pipeline and appends isTargetedActivity=true as a query parameter to API URLs when enabled.
Key changes:
- Added
is_targetedparameter to send, update, and reply operations across all layers (API, apps, devtools) - Implemented URL query parameter handling to append
isTargetedActivity=truewhen targeted mode is enabled - Added validation to ensure
activity.recipientis set when using targeted messages
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
packages/api/src/microsoft_teams/api/clients/conversation/activity.py |
Implements URL query parameter construction for targeted messages in create, update, and reply methods |
packages/api/src/microsoft_teams/api/clients/conversation/client.py |
Propagates is_targeted parameter through the ActivityOperations interface |
packages/api/tests/unit/test_conversation_client.py |
Adds comprehensive test coverage for targeted message operations |
packages/apps/src/microsoft_teams/apps/http_plugin.py |
Implements recipient validation and conversation reference handling for targeted messages |
packages/apps/src/microsoft_teams/apps/plugins/sender.py |
Updates the Sender protocol interface to include is_targeted parameter |
packages/apps/src/microsoft_teams/apps/routing/activity_context.py |
Adds is_targeted parameter to send and reply methods with documentation |
packages/apps/src/microsoft_teams/apps/contexts/function_context.py |
Implements recipient validation for targeted messages in function context |
packages/apps/src/microsoft_teams/apps/app.py |
Adds targeted message support to the App's proactive send method |
packages/apps/src/microsoft_teams/apps/app_process.py |
Propagates is_targeted parameter through the process layer |
packages/apps/tests/test_function_context.py |
Updates test assertions to verify is_targeted parameter handling |
packages/devtools/src/microsoft_teams/devtools/devtools_plugin.py |
Forwards is_targeted parameter to the HTTP plugin |
packages/api/src/microsoft_teams/api/clients/conversation/activity.py
Outdated
Show resolved
Hide resolved
| url = f"{self.service_url}/v3/conversations/{conversation_id}/activities/{activity_id}" | ||
| if is_targeted: | ||
| url += "?isTargetedActivity=true" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you need to have "isTargeted" for delete messages?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes based on service side design, we need to pass isTargetedActivity for update and delete.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is being discussed
| Returns: | ||
| The updated activity | ||
| """ | ||
| url = f"{self.service_url}/v3/conversations/{conversation_id}/activities/{activity_id}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you need to have "isTargeted" for update messages?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes based on service design, we need to pass isTargetedActivity for update and delete.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should you revisit that? That doesn't really make sense though right? After an activity is created, the fact that it's targeted/not targeted is irrelevant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are currently required for correct routing in APX and IC3 so they invoke the targeted handlers and apply the right validations. If dropped, the call goes through the normal message route and the activity cannot be resolved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So a user needs to record the fact that an activity is targeted or not if they want to update it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is being discussed
packages/apps/src/microsoft_teams/apps/contexts/function_context.py
Outdated
Show resolved
Hide resolved
packages/apps/src/microsoft_teams/apps/contexts/function_context.py
Outdated
Show resolved
Hide resolved
|
@ShanmathiMayuramKrithivasan have you tested this? |
packages/api/src/microsoft_teams/api/clients/conversation/activity.py
Outdated
Show resolved
Hide resolved
packages/apps/src/microsoft_teams/apps/contexts/function_context.py
Outdated
Show resolved
Hide resolved
| Returns: | ||
| The updated activity | ||
| """ | ||
| url = f"{self.service_url}/v3/conversations/{conversation_id}/activities/{activity_id}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should you revisit that? That doesn't really make sense though right? After an activity is created, the fact that it's targeted/not targeted is irrelevant
packages/devtools/src/microsoft_teams/devtools/devtools_plugin.py
Outdated
Show resolved
Hide resolved
packages/api/src/microsoft_teams/api/clients/conversation/activity.py
Outdated
Show resolved
Hide resolved
packages/api/src/microsoft_teams/api/clients/conversation/activity.py
Outdated
Show resolved
Hide resolved
heyitsaamir
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind creating a new test for this?
cookiecutter templates/test -o examples. If you run this, it'll scaffold a new test for you. (This will help us maintain this feature in the future).
| Returns: | ||
| The updated activity | ||
| """ | ||
| url = f"{self.service_url}/v3/conversations/{conversation_id}/activities/{activity_id}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So a user needs to record the fact that an activity is targeted or not if they want to update it?
Add support for Targeted Messages
This PR introduces support for sending targeted messages - messages delivered privately to a specific recipient within a conversation.
Key Updates:
Added an is_targeted boolean parameter to the send, update, reply and Delete APIs. When enabled, the message is sent privately to the Recipient.Id specified in the activity payload.
We append isTargetedActivity=true as a query parameter in API URLs when isTargeted is set, allowing backend services to correctly process these requests.