Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,20 @@ app.OnMessage(async context =>
await context.Send(new MessageActivity("hi!").AddMention(activity.From));
});
```

<!-- targeted-method-name -->

`WithTargetedRecipient`

<!-- targeted-send-example -->

```csharp
app.OnMessage(async context =>
{
// Using WithTargetedRecipient(true) automatically targets the sender of the incoming message
await context.Send(
new MessageActivity("This message is only visible to you!")
.WithTargetedRecipient(true)
);
});
```
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,19 @@ public static class Notifications
await app.Send(conversationId, "Hey! It's been a while. How are you?");
}
}
```

<!-- targeted-proactive-example -->

```csharp
// When sending proactively, you must provide the explicit user ID
public static async Task SendTargetedNotification(string conversationId, string userId)
{
var teams = app.UseTeams();
await teams.Send(
conversationId,
new MessageActivity("This is a private notification just for you!")
.WithTargetedRecipient(userId)
Comment on lines +43 to +50
Copy link

Copilot AI Feb 11, 2026

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.

Suggested change
// When sending proactively, you must provide the explicit user ID
public static async Task SendTargetedNotification(string conversationId, string userId)
{
var teams = app.UseTeams();
await teams.Send(
conversationId,
new MessageActivity("This is a private notification just for you!")
.WithTargetedRecipient(userId)
// When sending proactively, you must provide the user's AAD object ID as the targeted recipient ID
public static async Task SendTargetedNotification(string conversationId, string userAadObjectId)
{
var teams = app.UseTeams();
await teams.Send(
conversationId,
new MessageActivity("This is a private notification just for you!")
.WithTargetedRecipient(userAadObjectId)

Copilot uses AI. Check for mistakes.
);
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link

Copilot AI Feb 11, 2026

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 elsewhere the examples use AAD object ID as the user identifier (e.g., ctx.activity.from_.aad_object_id). Consider clarifying which user identifier should be passed to with_targeted_recipient(...) to avoid confusion.

Suggested change
# 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)

Copilot uses AI. Check for mistakes.
)
```
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link

Copilot AI Feb 11, 2026

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 rest of the proactive messaging examples use the user’s AAD object ID (activity.from.aadObjectId) as the user identifier. Consider renaming the parameter/comment to explicitly reference the AAD object ID (or whatever identifier the SDK requires) to avoid confusion.

Copilot uses AI. Check for mistakes.
conversationId,
new MessageActivity('This is a private notification just for you!')
.withTargetedRecipient(userId)
);
};
```
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,22 @@ async def handle_message(ctx: ActivityContext[MessageActivity]):
async def handle_message(ctx: ActivityContext[MessageActivity]):
await ctx.send(MessageActivityInput(text='hi!').add_mention(account=ctx.activity.from_))
```

<!-- targeted-method-name -->

`with_targeted_recipient`

<!-- targeted-send-example -->

```python
from microsoft_teams.api import MessageActivity, MessageActivityInput
from microsoft_teams.apps import ActivityContext

@app.on_message
async def handle_message(ctx: ActivityContext[MessageActivity]):
# Using with_targeted_recipient(True) automatically targets the sender of the incoming message
await ctx.send(
MessageActivityInput(text="This message is only visible to you!")
.with_targeted_recipient(True)
)
```
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,21 @@ app.on('message', async ({ send, activity }) => {
await send(new MessageActivity('hi!').addMention(activity.from));
});
```

<!-- targeted-method-name -->

`withTargetedRecipient`

<!-- targeted-send-example -->

```typescript
import { MessageActivity } from '@microsoft/teams.api';

app.on('message', async ({ send }) => {
// Using withTargetedRecipient(true) automatically targets the sender of the incoming message
await send(
new MessageActivity('This message is only visible to you!')
.withTargetedRecipient(true)
);
});
```
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

The admonition title syntax here (":::info[Preview]") is inconsistent with the rest of the docs, which use the space-delimited title form (e.g. ":::info Azure Setup Required"). Consider switching to ":::info Preview" for consistency and to avoid potential admonition parsing issues.

Copilot uses AI. Check for mistakes.

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.
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

Grammar: “Targeted messages … are delivered … From a single user's perspective, it appears …” mixes plural and singular. Consider changing “it appears” to “they appear” to match the plural subject.

Suggested change
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.

Copilot uses AI. Check for mistakes.

To send a targeted message when responding to an incoming activity, use the <LanguageInclude section="targeted-method-name" /> method. The recipient will automatically be set to the user who sent the incoming message.

<LanguageInclude section="targeted-send-example" />
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

The admonition title syntax here (":::info[Preview]") doesn’t match the rest of the docs, which use the space-delimited title form (e.g. ":::info Azure Setup Required" in essentials/app-authentication.mdx). Consider changing to the consistent form (":::info Preview") to avoid rendering/build issues.

Copilot uses AI. Check for mistakes.

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.
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

Grammar: “Targeted messages … are delivered … From a single user's perspective, it appears …” mixes plural and singular. Consider changing “it appears” to “they appear” to match “Targeted messages … are delivered”.

Suggested change
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 uses AI. Check for mistakes.

When sending targeted messages proactively, you must explicitly specify the recipient's user ID.
Copy link

Copilot AI Feb 11, 2026

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.

Suggested change
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`).

Copilot uses AI. Check for mistakes.

<LanguageInclude section="targeted-proactive-example" />