Skip to content
Open
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
64 changes: 42 additions & 22 deletions msteams-platform/bots/how-to/conversations/prompt-suggestions.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Add Prompt Suggestions
description: Learn how to create and handle a prompt starter and suggested actions for your Microsoft Teams bot to help your users initiate conversations.
ms.topic: how-to
ms.localizationpriority: medium
ms.date: 10/25/2024
ms.date: 04/14/2026
---

# Create prompt suggestions
Expand Down Expand Up @@ -155,48 +155,68 @@ Bots in a group or channel respond only when they're @mentioned in a message. Ev

# [C#](#tab/dotnet)

* [SDK reference](/dotnet/api/microsoft.bot.schema.activityextensions.removerecipientmention?view=botbuilder-dotnet-stable#microsoft-bot-schema-activityextensions-removerecipientmention(microsoft-bot-schema-imessageactivity)&preserve-view=true)
* [Sample code reference](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/TeamsSDK/bot-quickstart/dotnet/bot-quickstart)

* [Sample code reference](https://github.com/OfficeDev/Microsoft-Teams-Samples/blob/main/samples/app-hello-world/csharp/Microsoft.Teams.Samples.HelloWorld.Web/Bots/MessageExtension.cs#L19)

You can parse out the **\@Mention** portion of the message text using a static method provided with the Microsoft Bot Framework. It's a method of the `Activity` class named `RemoveRecipientMention`.

The C# code to parse out the **\@Mention** portion of the message text is as follows:
In C#, Teams SDK does not feature a method to remove **\@Mention** portion. You can refer to the code snippet below on how to handle commands in your bot.

```csharp
Comment thread
Pranjal-MSFT marked this conversation as resolved.
// Remove recipient mention text from Text property.
// Use with caution because this function is altering the text on the Activity.
var modifiedText = turnContext.Activity.RemoveRecipientMention();
```
// Handles incoming messages and routes to appropriate functions based on message content
teamsApp.OnMessage(async context =>
{
// Get message text and normalize it
var text = (context.Activity.Text ?? "").Trim().ToLower();
Comment thread
Pranjal-MSFT marked this conversation as resolved.

# [JavaScript](#tab/javascript)
// Handle mention me command - use exact matching to avoid false positives from substrings
if (text == "mentionme" || text == "mention me")
{
Comment thread
Pranjal-MSFT marked this conversation as resolved.
await MentionUser(context);
}
// Handle whoami command
else if (text == "whoami")
{
await GetSingleMember(context);
}
// Handle welcome command
else if (text == "welcome")
{
await SendWelcomeMessage(context);
}
// Echo greeting messages
else if (text == "hi" || text == "hello")
{
await EchoMessage(context, text);
}
else
{
await SendWelcomeMessage(context);
}
});
```

* [SDK reference](/javascript/api/botbuilder-core/turncontext?view=botbuilder-ts-latest#botbuilder-core-turncontext-removementiontext&preserve-view=true)
# [TypeScript](#tab/typescript)

* [Sample code reference](https://github.com/OfficeDev/Microsoft-Teams-Samples/blob/main/samples/bot-people-picker-adaptive-card/nodejs/bots/teamsBot.js#L21)
* [Sample code reference](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/TeamsSDK/bot-quickstart/nodejs/bot-quickstart)

You can parse out the **\@Mention** portion of the message text using a static method provided with the Bot Framework. It's a method of the `TurnContext` class named `removeMentionText`.
You can parse out the **\@Mention** portion of the message text using a static method provided with Teams SDK. It's a method of the `TurnContext` class named `stripMentionsText`.

The JavaScript code to parse out the **\@Mention** portion of the message text is as follows:

```javascript
```typescript
// Remove mention text from Text property, this function is altering the text on the Activity.
const modifiedText = TurnContext.removeMentionText(turnContext.activity, turnContext.activity.recipient.id);
const text = context.activity.stripMentionsText().text.trim().toLowerCase();
```

# [Python](#tab/python)

* [SDK reference](/python/api/botbuilder-core/botbuilder.core.turncontext?view=botbuilder-py-latest#botbuilder-core-turncontext-remove-recipient-mention&preserve-view=true)

* [Sample code reference](https://github.com/OfficeDev/Microsoft-Teams-Samples/blob/main/samples/bot-conversation/python/bots/teams_conversation_bot.py#L34)
* [Sample code reference](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/TeamsSDK/bot-quickstart/python/bot-quickstart)

You can parse out the **@Mention** portion of the message text using a static method provided with the Bot Framework. It's a method of the `TurnContext` class named `remove_recipient_mention`.
You can parse out the **@Mention** portion of the message text using a static method provided with Teams SDK. It's a method of the `TurnContext` class named `strip_mentions_text`.

The Python code to parse out the **\@Mention** portion of the message text is as follows:

```python
# Remove recipient mention text from Text property, this function is altering the text on the Activity.
modified_text = TurnContext.remove_recipient_mention(turn_context.activity)
text = context.activity.strip_mentions_text().text. Strip().lower()
```

* * *
Expand Down
27 changes: 15 additions & 12 deletions msteams-platform/includes/bots/suggested-actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Here are some examples that show how to implement and experience suggested actio

# [`imBack`](#tab/iamback)

To add suggested actions to a message, specify a list of [card action](/azure/bot-service/rest-api/bot-framework-rest-connector-api-reference) objects that represent the buttons to be displayed to the user for the [`suggestedActions`](/dotnet/api/microsoft.bot.builder.messagefactory.suggestedactions) property of the [activity](/azure/bot-service/rest-api/bot-framework-rest-connector-api-reference) object.
To add suggested actions to a message, specify a list of [card action](https://github.com/microsoft/teams.ts/blob/main/packages/api/src/models/card/card-action.ts) objects that represent the buttons to be displayed to the user for the [`suggestedActions`](https://github.com/microsoft/teams.ts/blob/main/packages/api/src/models/suggested-actions.ts) property of the [activity](https://github.com/microsoft/teams.ts/blob/main/packages/api/src/activities/activity.ts) object.
Comment thread
Pranjal-MSFT marked this conversation as resolved.

The following is an example to implement suggested actions using `imBack`:

Expand Down Expand Up @@ -91,22 +91,25 @@ The following is an example to implement suggested actions using `imBack`:

You can use the `Action.Compose` to insert a message in the compose box, which helps you add a new action type. This action enables you to include semantic objects like tags, mention users in the chat or channel, and other rich objects like emojis and gifs.

The following code snippet shows an example of implementing `Action.Compose`:
The following code snippet shows a minimal example of implementing `Action.Compose`:

```json
{
Type: “Action.Compose”,
Title: “button title”,
Value: {
type: “Teams.chatMessage”,
data: <GraphAPI Chat Message Object>
}
{
"type": "Action.Compose",
"title": "button title",
"value": {
"type": "Teams.chatMessage",
"data": {
"body": {
"contentType": "html",
"content": "Hello from Action.Compose"
}
}
}
}
```

The value object must follow the [`chatMessage`](/graph/api/resources/chatmessage?view=graph-rest-1.0&preserve-view=true) object in the Graph API.

For more information, see [code sample](https://github.com/OfficeDev/Microsoft-Teams-Samples/blob/35c8a5bab588974c1f082225bccd67b13a31741d/samples/bot-suggested-actions/nodejs/bots/suggestedActionsBot.js#L61).
The `value.data` object must follow the Microsoft Graph [`chatMessage`](/graph/api/resources/chatmessage?view=graph-rest-1.0&preserve-view=true) schema. Use that reference to add supported message content such as mentions, tags, emojis, gifs, and other rich objects.

> [!NOTE]
> If the message is received in a hub that doesn't support it, the app shows an error message. The bots are aware of the channel to which its posting.
Expand Down