-
Notifications
You must be signed in to change notification settings - Fork 261
[Docs] Add Targeted Messages Support #2707
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -34,4 +34,18 @@ async def send_proactive_notification(user_id: str): | |||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||||
| activity = MessageActivityInput(text="Hey! It's been a while. How are you?") | ||||||||||||||||||||||||||||
| await app.send(conversation_id, activity) | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| <!-- targeted-proactive-example --> | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ```python | ||||||||||||||||||||||||||||
| from microsoft_teams.api import MessageActivityInput | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # When sending proactively, you must provide the explicit user ID | ||||||||||||||||||||||||||||
| async def send_targeted_notification(conversation_id: str, user_id: str): | ||||||||||||||||||||||||||||
| await app.send( | ||||||||||||||||||||||||||||
| conversation_id, | ||||||||||||||||||||||||||||
| MessageActivityInput(text="This is a private notification just for you!") | ||||||||||||||||||||||||||||
| .with_targeted_recipient(user_id) | ||||||||||||||||||||||||||||
|
Comment on lines
+44
to
+49
|
||||||||||||||||||||||||||||
| # When sending proactively, you must provide the explicit user ID | |
| async def send_targeted_notification(conversation_id: str, user_id: str): | |
| await app.send( | |
| conversation_id, | |
| MessageActivityInput(text="This is a private notification just for you!") | |
| .with_targeted_recipient(user_id) | |
| # When sending proactively, you must provide the user's AAD object ID | |
| # (for example, ctx.activity.from_.aad_object_id from an earlier activity) | |
| async def send_targeted_notification(conversation_id: str, aad_object_id: str): | |
| await app.send( | |
| conversation_id, | |
| MessageActivityInput(text="This is a private notification just for you!") | |
| .with_targeted_recipient(aad_object_id) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,4 +38,19 @@ const sendProactiveNotification = async (userId: string) => { | |
| const activity = new MessageActivity('Hey! It\'s been a while. How are you?'); | ||
| await app.send(conversationId, activity); | ||
| }; | ||
| ``` | ||
|
|
||
| <!-- targeted-proactive-example --> | ||
|
|
||
| ```typescript | ||
| import { MessageActivity } from '@microsoft/teams.api'; | ||
|
|
||
| // When sending proactively, you must provide the explicit user ID | ||
| const sendTargetedNotification = async (conversationId: string, userId: string) => { | ||
| await app.send( | ||
|
Comment on lines
+48
to
+50
|
||
| conversationId, | ||
| new MessageActivity('This is a private notification just for you!') | ||
| .withTargetedRecipient(userId) | ||
| ); | ||
| }; | ||
| ``` | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -37,3 +37,15 @@ Streaming is currently only supported in 1:1 conversations, not group chats or c | |||||
| Sending a message at `@mentions` a user is as simple including the details of the user using the <LanguageInclude section="mention-method-name" /> method | ||||||
|
|
||||||
| <LanguageInclude section="mention-example" /> | ||||||
|
|
||||||
| ## Targeted Messages | ||||||
|
|
||||||
| :::info[Preview] | ||||||
| Targeted messages are currently in preview. | ||||||
| ::: | ||||||
|
Comment on lines
+43
to
+45
|
||||||
|
|
||||||
| Targeted messages, also known as ephemeral messages, are delivered to a specific user in a shared conversation. From a single user's perspective, it appears as regular inline messages in a conversation. Other participants won't see these messages, making them useful for authentication flows, help or error responses, personal reminders, or sharing contextual information without cluttering the group conversation. | ||||||
|
||||||
| Targeted messages, also known as ephemeral messages, are delivered to a specific user in a shared conversation. From a single user's perspective, it appears as regular inline messages in a conversation. Other participants won't see these messages, making them useful for authentication flows, help or error responses, personal reminders, or sharing contextual information without cluttering the group conversation. | |
| Targeted messages, also known as ephemeral messages, are delivered to a specific user in a shared conversation. From a single user's perspective, they appear as regular inline messages in a conversation. Other participants won't see these messages, making them useful for authentication flows, help or error responses, personal reminders, or sharing contextual information without cluttering the group conversation. |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -20,3 +20,15 @@ Then, when you want to send a proactive message, you can retrieve the <LanguageI | |||||
| :::tip | ||||||
| In this example, you see how to get the <LanguageInclude section="conversation-id-field" /> using one of the activity handlers. This is a good place to store the conversation id, but you can also do this in other places like when the user installs the app or when they sign in. The important thing is that you have the conversation id stored somewhere so you can use it later. | ||||||
| ::: | ||||||
|
|
||||||
| ## Targeted Proactive Messages | ||||||
|
|
||||||
| :::info[Preview] | ||||||
| Targeted messages are currently in preview. | ||||||
| ::: | ||||||
|
Comment on lines
+26
to
+28
|
||||||
|
|
||||||
| Targeted messages, also known as ephemeral messages, are delivered to a specific user in a shared conversation. From a single user's perspective, it appears as regular inline messages in a conversation. Other participants won't see these messages. | ||||||
|
||||||
| Targeted messages, also known as ephemeral messages, are delivered to a specific user in a shared conversation. From a single user's perspective, it appears as regular inline messages in a conversation. Other participants won't see these messages. | |
| Targeted messages, also known as ephemeral messages, are delivered to a specific user in a shared conversation. From a single user's perspective, they appear as regular inline messages in a conversation. Other participants won't see these messages. |
Copilot
AI
Feb 11, 2026
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 text says to specify the recipient’s “user ID”, but earlier examples key users by AAD object ID (e.g., activity.from.aadObjectId). Consider clarifying which identifier is required for targeted recipients (AAD object ID vs another Teams user identifier) to prevent misuse.
| When sending targeted messages proactively, you must explicitly specify the recipient's user ID. | |
| When sending targeted messages proactively, you must explicitly specify the recipient's Azure AD (AAD) object ID (for example, the value from `activity.from.aadObjectId`). |
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 comment says “explicit user ID”, but the surrounding docs/examples typically use the user’s AAD object ID as the identifier. Consider clarifying the expected identifier (AAD object ID vs another Teams user identifier) for WithTargetedRecipient(...) so readers pass the correct value.