Updates from: 01/28/2023 05:22:19
Service Microsoft Docs article Related commit history on GitHub Change details
platform Bot Basics https://github.com/MicrosoftDocs/msteams-docs/commits/main/msteams-platform/bots/bot-basics.md
The code snippets for Teams activity handlers:
`OnTeamsChannelCreatedAsync` ```csharp- protected override Task OnTeamsChannelCreatedAsync(ChannelInfo channelInfo, TeamInfo teamInfo, ITurnContext<IConversationUpdateActivity> turnContext, CancellationToken cancellationToken) { // Code logic here
protected override Task OnTeamsChannelCreatedAsync(ChannelInfo channelInfo, Team
`OnTeamsChannelDeletedAsync` ```csharp- protected override Task OnTeamsChannelDeletedAsync(ChannelInfo channelInfo, TeamInfo teamInfo, ITurnContext<IConversationUpdateActivity> turnContext, CancellationToken cancellationToken) { // Code logic here
protected override Task OnTeamsChannelDeletedAsync(ChannelInfo channelInfo, Team
`OnTeamsChannelRenamedAsync` ```csharp- protected override Task OnTeamsChannelRenamedAsync(ChannelInfo channelInfo, TeamInfo teamInfo, ITurnContext<IConversationUpdateActivity> turnContext, CancellationToken cancellationToken) { // Code logic here
protected override Task OnTeamsChannelRenamedAsync(ChannelInfo channelInfo, Team
`OnTeamsTeamRenamedAsync` ```csharp- protected override Task OnTeamsTeamRenamedAsync(TeamInfo teamInfo, ITurnContext<IConversationUpdateActivity> turnContext, CancellationToken cancellationToken) { // Code logic here
protected override Task OnTeamsTeamRenamedAsync(TeamInfo teamInfo, ITurnContext<
`OnTeamsMembersAddedAsync` ```csharp- protected override Task OnTeamsMembersAddedAsync(IList<TeamsChannelAccount> teamsMembersAdded, TeamInfo teamInfo, ITurnContext<IConversationUpdateActivity> turnContext, CancellationToken cancellationToken) { // Code logic here
protected override Task OnTeamsMembersAddedAsync(IList<TeamsChannelAccount> team
`OnTeamsMembersRemovedAsync` ```csharp- protected override Task OnTeamsMembersRemovedAsync(IList<TeamsChannelAccount> teamsMembersRemoved, TeamInfo teamInfo, ITurnContext<IConversationUpdateActivity> turnContext, CancellationToken cancellationToken); { // Code logic here } ```
+`OnTeamsMessageEditAsync`
+
+```csharp
+protected override async Task OnTeamsMessageEditAsync(ITurnContext<IMessageUpdateActivity> turnContext, CancellationToken cancellationToken)
+ {
+ // Code logic here
+ }
+```
+
+`OnTeamsMessageUndeleteAsync`
+
+```csharp
+protected override async Task OnTeamsMessageUndeleteAsync(ITurnContext<IMessageUpdateActivity> turnContext, CancellationToken cancellationToken)
+ {
+ // Code logic here
+ }
+```
+
+`OnTeamsMessageSoftDeleteAsync`
+
+```csharp
+ protected override async Task OnTeamsMessageSoftDeleteAsync(ITurnContext<IMessageDeleteActivity> turnContext, CancellationToken cancellationToken)
+ {
+ // Code logic here
+ }
+```
+ # [JavaScript](#tab/javascript) Bots are created using the Bot Framework. If the bots receive a message activity, then the turn handler receives a notification of that incoming activity. The turn handler then sends the incoming activity to the `onMessage` activity handler. In Teams, this functionality remains the same. If the bot receives a conversation update activity, then the turn handler receives a notification of that incoming activity and sends the incoming activity to `dispatchConversationUpdateActivity`. The Teams activity handler first checks for any Teams specific events. If no events are found, it then passes them along to the Bot Framework's activity handler.
onTeamsMembersRemoved(async (membersRemoved, teamInfo, context, next) => {
Bots are created using the Bot Framework. If the bots receive a message activity, then the turn handler receives a notification of that incoming activity. The turn handler then sends the incoming activity to the `on_message_activity` activity handler. In Teams, this functionality remains the same. If the bot receives a conversation update activity, then the turn handler receives a notification of that incoming activity and sends the incoming activity to `on_conversation_update_activity`. The Teams activity handler first checks for any Teams specific events. If no events are found, it then passes them along to the Bot Framework's activity handler.
-In the Teams activity handler class, there are two primary Teams activity handlers, `on_conversation_update_activity` and `on_invoke_activity`. `on_conversation_update_activity` routes all conversation update activities and `on_invoke_activity` routes all Teams invoke activities.
+In the Teams activity handler class, there are two primary Teams activity handlers, `on_conversation_update_activity` and `on_invoke_activity`. `on_conversation_update_activity` routes all conversation update activities and `on_invoke_activity` routes all Teams invokes activities.
To implement your logic for Teams specific activity handlers, you must override the methods in your bot as shown in the [bot logic](#bot-logic) section. There's no base implementation for these handlers. Therefore, add the logic that you want in your override.
The list of handlers defined in `ActivityHandler` includes the following events:
| Event | Handler | Description | | :-- | :-- | :-- | | Any activity type received | `OnTurnAsync` | This method calls one of the other handlers, based on the type of activity received. |
-| Message activity received | `OnMessageActivityAsync` | This method can be overridden to handle a `Message` activity. |
+| Message activity received | `OnMessageActivityAsync` | You can override this method to handle a `Message` activity. |
+| Message update activity received | `OnMessageUpdateActivityAsync` | You can override this method to handle a message update activity. |
+| Message delete activity received | `OnMessageDeleteActivityAsync` | You can override this method to handle a message delete activity. |
| Conversation update activity received | `OnConversationUpdateActivityAsync` | This method calls a handler if members other than the bot joined or left the conversation, on a `ConversationUpdate` activity. |
-| Non-bot members joined the conversation | `OnMembersAddedAsync` | This method can be overridden to handle members joining a conversation. |
-| Non-bot members left the conversation | `OnMembersRemovedAsync` | This method can be overridden to handle members leaving a conversation. |
+| Non-bot members joined the conversation | `OnMembersAddedAsync` | You can override this method to handle members joining a conversation. |
+| Non-bot members left the conversation | `OnMembersRemovedAsync` | You can override this method to handle members leaving a conversation. |
| Event activity received | `OnEventActivityAsync` | This method calls a handler specific to the event type, on an `Event` activity. |
-| Token-response event activity received | `OnTokenResponseEventAsync` | This method can be overridden to handle token response events. |
-| Non-token-response event activity received | `OnEventAsync` | This method can be overridden to handle other types of events. |
-| Other activity type received | `OnUnrecognizedActivityTypeAsync` | This method can be overridden to handle any activity type otherwise unhandled. |
+| Token-response event activity received | `OnTokenResponseEventAsync` | You can override this method to handle token response events. |
+| Non-token-response event activity received | `OnEventAsync` | You can override this method to handle other types of events. |
+| Other activity type received | `OnUnrecognizedActivityTypeAsync` | You can override this method to handle any activity type otherwise unhandled. |
#### Teams specific activity handlers
The `TeamsActivityHandler` extends the list of handlers in the core Bot Framewor
| Event | Handler | Description | | :-- | :-- | :-- |
-| channelCreated | `OnTeamsChannelCreatedAsync` | This method can be overridden to handle a Teams channel being created. For more information, see [channel created](how-to/conversations/subscribe-to-conversation-events.md#channel-created) in [conversation update events](how-to/conversations/subscribe-to-conversation-events.md).|
-| channelDeleted | `OnTeamsChannelDeletedAsync` | This method can be overridden to handle a Teams channel being deleted. For more information, see [channel deleted](how-to/conversations/subscribe-to-conversation-events.md#channel-deleted) in [conversation update events](how-to/conversations/subscribe-to-conversation-events.md).|
-| channelRenamed | `OnTeamsChannelRenamedAsync` | This method can be overridden to handle a Teams channel being renamed. For more information, see [channel renamed](how-to/conversations/subscribe-to-conversation-events.md#channel-renamed) in [conversation update events](how-to/conversations/subscribe-to-conversation-events.md).|
-| teamRenamed | `OnTeamsTeamRenamedAsync` | `return Task.CompletedTask;` This method can be overridden to handle a Teams team being renamed. For more information, see [team renamed](how-to/conversations/subscribe-to-conversation-events.md#team-renamed) in [conversation update events](how-to/conversations/subscribe-to-conversation-events.md).|
-| MembersAdded | `OnTeamsMembersAddedAsync` | This method calls the `OnMembersAddedAsync` method in `ActivityHandler`. The method can be overridden to handle members joining a team. For more information, see [team members added](how-to/conversations/subscribe-to-conversation-events.md#members-added) in [conversation update events](how-to/conversations/subscribe-to-conversation-events.md).|
-| MembersRemoved | `OnTeamsMembersRemovedAsync` | This method calls the `OnMembersRemovedAsync` method in `ActivityHandler`. The method can be overridden to handle members leaving a team. For more information, see [team members removed](how-to/conversations/subscribe-to-conversation-events.md#members-removed) in [conversation update events](how-to/conversations/subscribe-to-conversation-events.md).|
+| channelCreated | `OnTeamsChannelCreatedAsync` | You can override this method to handle a Teams channel being created. For more information, see [channel created](https://aka.ms/azure-bot-subscribe-to-conversation-events#channel-created) in [conversation update events](https://aka.ms/azure-bot-subscribe-to-conversation-events). |
+| channelDeleted | `OnTeamsChannelDeletedAsync` | You can override this method to handle a Teams channel being deleted. For more information, see [channel deleted](https://aka.ms/azure-bot-subscribe-to-conversation-events#channel-deleted) in [conversation update events](https://aka.ms/azure-bot-subscribe-to-conversation-events).|
+| channelRenamed | `OnTeamsChannelRenamedAsync` | You can override this method to handle a Teams channel being renamed. For more information, see [channel renamed](https://aka.ms/azure-bot-subscribe-to-conversation-events#channel-renamed) in [conversation update events](https://aka.ms/azure-bot-subscribe-to-conversation-events).|
+| teamRenamed | `OnTeamsTeamRenamedAsync` | `return Task.CompletedTask;` You can override this method to handle a Teams team being renamed. For more information, see [team renamed](https://aka.ms/azure-bot-subscribe-to-conversation-events#team-renamed) in [conversation update events](https://aka.ms/azure-bot-subscribe-to-conversation-events).|
+| MembersAdded | `OnTeamsMembersAddedAsync` | This method calls the `OnMembersAddedAsync` method in `ActivityHandler`. You can override this method to handle members joining a team. For more information, see [team members added](https://aka.ms/azure-bot-subscribe-to-conversation-events#team-members-added) in [conversation update events](https://aka.ms/azure-bot-subscribe-to-conversation-events).|
+| MembersRemoved | `OnTeamsMembersRemovedAsync` | This method calls the `OnMembersRemovedAsync` method in `ActivityHandler`. You can override this method to handle members leaving a team. For more information, see [team members removed](https://aka.ms/azure-bot-subscribe-to-conversation-events#team-members-removed) in [conversation update events](https://aka.ms/azure-bot-subscribe-to-conversation-events).|
+| messageEdit | `OnTeamsMessageEditAsync` | You can override this method to handle a Teams message edit event. |
+| messageUndelete | `OnTeamsMessageUndeleteAsync` | You can override this method to handle a Teams message undelete event. |
+| messageSoftDelete | `OnTeamsMessageSoftDeleteAsync` | You can override this method to handle a Teams message soft delete event. |
#### Teams invoke activities
The list of Teams activity handlers called from the `OnInvokeActivityAsync` Team
| fileConsent/invoke | `OnTeamsFileConsentDeclineAsync` | This method is invoked when a file consent card is declined by the user. | | actionableMessage/executeAction | `OnTeamsO365ConnectorCardActionAsync` | This method is invoked when a connector card for Microsoft 365 Groups action activity is received from the connector. | | signin/verifyState | `OnTeamsSigninVerifyStateAsync` | This method is invoked when a signIn verify state activity is received from the connector. |
-| task/fetch | `OnTeamsTaskModuleFetchAsync` | This method can be overridden in a derived class to provide logic when a task module is fetched. |
-| task/submit | `OnTeamsTaskModuleSubmitAsync` | This method can be overridden in a derived class to provide logic when a task module is submitted. |
+| task/fetch | `OnTeamsTaskModuleFetchAsync` | You can override this method in a derived class to provide logic when a task module is fetched. |
+| task/submit | `OnTeamsTaskModuleSubmitAsync` | You can override this method in a derived class to provide logic when a task module is submitted. |
The Invoke activities listed in this section are for conversational bots in Teams. The Bot Framework SDK also supports invoke activities specific to message extensions. For more information, see [what are message extensions](../messaging-extensions/what-are-messaging-extensions.md).
The list of handlers defined in `ActivityHandler` includes the following events:
| :-- | :-- | :-- | | Any activity type received | `onTurn` | This method calls one of the other handlers, based on the type of activity received. | | Message activity received | `onMessage` | This method helps to handle a `Message` activity. |
+| Message update activity received | `onMessageUpdate` | This method calls a handler if a message is updated. |
+| Message delete activity received | `onMessageDelete` | This method calls a handler if a message is deleted. |
| Conversation update activity received | `onConversationUpdate` | This method calls a handler if members other than the bot joined or left the conversation, on a `ConversationUpdate` activity. | | Non-bot members joined the conversation | `onMembersAdded` | This method helps to handle members joining a conversation. | | Non-bot members left the conversation | `onMembersRemoved` | This method helps to handle members leaving a conversation. |
The `TeamsActivityHandler` extends the list of handlers in the core Bot Framewor
| Event | Handler | Description | | :-- | :-- | :-- |
-| channelCreated | `OnTeamsChannelCreatedAsync` | This method can be overridden to handle a Teams channel being created. For more information, see [channel created](how-to/conversations/subscribe-to-conversation-events.md#channel-created) in [conversation update events](how-to/conversations/subscribe-to-conversation-events.md). |
-| channelDeleted | `OnTeamsChannelDeletedAsync` | This method can be overridden to handle a Teams channel being deleted. For more information, see [channel deleted](how-to/conversations/subscribe-to-conversation-events.md#channel-deleted) in [conversation update events](how-to/conversations/subscribe-to-conversation-events.md).|
-| channelRenamed | `OnTeamsChannelRenamedAsync` | This method can be overridden to handle a Teams channel being renamed. For more information, see [channel renamed](how-to/conversations/subscribe-to-conversation-events.md#channel-renamed) in [conversation update events](how-to/conversations/subscribe-to-conversation-events.md). |
-| teamRenamed | `OnTeamsTeamRenamedAsync` | `return Task.CompletedTask;` This method can be overridden to handle a Teams team being renamed. For more information, see [team renamed](how-to/conversations/subscribe-to-conversation-events.md#team-renamed) in [conversation update events](how-to/conversations/subscribe-to-conversation-events.md). |
-| MembersAdded | `OnTeamsMembersAddedAsync` | This method calls the `OnMembersAddedAsync` method in `ActivityHandler`. The method can be overridden to handle members joining a team. For more information, see [team members added](how-to/conversations/subscribe-to-conversation-events.md#members-added) in [conversation update events](how-to/conversations/subscribe-to-conversation-events.md). |
-| MembersRemoved | `OnTeamsMembersRemovedAsync` | This method calls the `OnMembersRemovedAsync` method in `ActivityHandler`. The method can be overridden to handle members leaving a team. For more information, see [team members removed](how-to/conversations/subscribe-to-conversation-events.md#members-removed) in [conversation update events](how-to/conversations/subscribe-to-conversation-events.md). |
+| channelCreated | `OnTeamsChannelCreatedAsync` | You can override this method to handle a Teams channel being created. For more information, see [channel created](https://aka.ms/azure-bot-subscribe-to-conversation-events#channel-created) in [conversation update events](https://aka.ms/azure-bot-subscribe-to-conversation-events). |
+| channelDeleted | `OnTeamsChannelDeletedAsync` | You can override this method to handle a Teams channel being deleted. For more information, see [channel deleted](https://aka.ms/azure-bot-subscribe-to-conversation-events#channel-deleted) in [conversation update events](https://aka.ms/azure-bot-subscribe-to-conversation-events).|
+| channelRenamed | `OnTeamsChannelRenamedAsync` | You can override this method to handle a Teams channel being renamed. For more information, see [channel renamed](https://aka.ms/azure-bot-subscribe-to-conversation-events#channel-renamed) in [conversation update events](https://aka.ms/azure-bot-subscribe-to-conversation-events). |
+| teamRenamed | `OnTeamsTeamRenamedAsync` | `return Task.CompletedTask;` You can override this method to handle a Teams team being renamed. For more information, see [team renamed](https://aka.ms/azure-bot-subscribe-to-conversation-events#team-renamed) in [conversation update events](https://aka.ms/azure-bot-subscribe-to-conversation-events). |
+| MembersAdded | `OnTeamsMembersAddedAsync` | This method calls the `OnMembersAddedAsync` method in `ActivityHandler`. You can override this method to handle members joining a team. For more information, see [team members added](https://aka.ms/azure-bot-subscribe-to-conversation-events#team-members-added) in [conversation update events](https://aka.ms/azure-bot-subscribe-to-conversation-events). |
+| MembersRemoved | `OnTeamsMembersRemovedAsync` | This method calls the `OnMembersRemovedAsync` method in `ActivityHandler`. You can override this method to handle members leaving a team. For more information, see [team members removed](https://aka.ms/azure-bot-subscribe-to-conversation-events#team-members-removed) in [conversation update events](https://aka.ms/azure-bot-subscribe-to-conversation-events). |
+| message edit | `onTeamsMessageEditEvent` | You can override this method to handle when a message in a conversation is edited. |
+| message undelete | `onTeamsMessageUndeleteEvent` | You can override this method to handle when a deleted message in a conversation is undeleted. For example, when the user decides to undo a deleted message. |
+| message soft delete | `onTeamsMessageSoftDeleteEvent` | You can override this method to handle when a message in a conversation is soft deleted. |
#### Teams invoke activities
The list of Teams activity handlers called from the `onInvokeActivity` Teams act
| fileConsent/invoke | `handleTeamsFileConsentDecline` | This method is invoked when a file consent card is declined by the user. | | actionableMessage/executeAction | `handleTeamsO365ConnectorCardAction` | This method is invoked when a connector card for Microsoft 365 Groups action activity is received from the connector. | | signin/verifyState | `handleTeamsSigninVerifyState` | This method is invoked when a signIn verify state activity is received from the connector. |
-| task/fetch | `handleTeamsTaskModuleFetch` | This method can be overridden in a derived class to provide logic when a task module is fetched. |
-| task/submit | `handleTeamsTaskModuleSubmit` | This method can be overridden in a derived class to provide logic when a task module is submitted. |
+| task/fetch | `handleTeamsTaskModuleFetch` | You can override this method in a derived class to provide logic when a task module is fetched. |
+| task/submit | `handleTeamsTaskModuleSubmit` | You can override this method in a derived class to provide logic when a task module is submitted. |
The invoke activities listed in this section are for conversational bots in Teams. The Bot Framework SDK also supports invoke activities specific to message extensions. For more information, see [what are message extensions](../messaging-extensions/what-are-messaging-extensions.md).
The list of handlers defined in `ActivityHandler` includes the following events:
| Event | Handler | Description | | :-- | :-- | :-- | | Any activity type received | `on_turn` | This method calls one of the other handlers, based on the type of activity received. |
-| Message activity received | `on_message_activity` | This method can be overridden to handle a `Message` activity. |
+| Message activity received | `on_message_activity` | You can override this method to handle a `Message` activity. |
| Conversation update activity received | `on_conversation_update_activity` | This method calls a handler if members other than the bot join or leave the conversation. |
-| Non-bot members joined the conversation | `on_members_added_activity` | This method can be overridden to handle members joining a conversation. |
-| Non-bot members left the conversation | `on_members_removed_activity` | This method can be overridden to handle members leaving a conversation. |
+| Non-bot members joined the conversation | `on_members_added_activity` | You can override this method to handle members joining a conversation. |
+| Non-bot members left the conversation | `on_members_removed_activity` | You can override this method to handle members leaving a conversation. |
| Event activity received | `on_event_activity` | This method calls a handler specific to the type of event. |
-| Token-response event activity received | `on_token_response_event` | This method can be overridden to handle token response events. |
-| Non-token-response event activity received | `on_event` | This method can be overridden to handle other types of events. |
-| Other activity types received | `on_unrecognized_activity_type` | This method can be overridden to handle any type of activity that isn't handled. |
+| Token-response event activity received | `on_token_response_event` | You can override this method to handle token response events. |
+| Non-token-response event activity received | `on_event` | You can override this method to handle other types of events. |
+| Other activity types received | `on_unrecognized_activity_type` | You can override this method to handle any type of activity that isn't handled. |
#### Teams specific activity handlers
The `TeamsActivityHandler` extends the list of handlers from the core Bot Framew
| Event | Handler | Description | | :-- | :-- | :-- |
-| channelCreated | `on_teams_channel_created` | This method can be overridden to handle a Teams channel being created. For more information, see [channel created](how-to/conversations/subscribe-to-conversation-events.md#channel-created) in [conversation update events](how-to/conversations/subscribe-to-conversation-events.md). |
-| channelDeleted | `on_teams_channel_deleted` | This method can be overridden to handle a Teams channel being deleted. For more information, see [channel deleted](how-to/conversations/subscribe-to-conversation-events.md#channel-deleted) in [conversation update events](how-to/conversations/subscribe-to-conversation-events.md).|
-| channelRenamed | `on_teams_channel_renamed` | This method can be overridden to handle a Teams channel being renamed. For more information, see [channel renamed](how-to/conversations/subscribe-to-conversation-events.md#channel-renamed) in [conversation update events](how-to/conversations/subscribe-to-conversation-events.md).|
-| teamRenamed | `on_teams_team_renamed` | `return Task.CompletedTask;` This method can be overridden to handle a Teams team being renamed. For more information, see [team renamed](how-to/conversations/subscribe-to-conversation-events.md#team-renamed) in [conversation update events](how-to/conversations/subscribe-to-conversation-events.md).|
-| MembersAdded | `on_teams_members_added` | This method calls the `OnMembersAddedAsync` method in `ActivityHandler`. The method can be overridden to handle members joining a team. For more information, see [team members added](how-to/conversations/subscribe-to-conversation-events.md#members-added) in [conversation update events](how-to/conversations/subscribe-to-conversation-events.md).|
-| MembersRemoved | `on_teams_members_removed` | This method calls the `OnMembersRemovedAsync` method in `ActivityHandler`. The method can be overridden to handle members leaving a team. For more information, see [team members removed](how-to/conversations/subscribe-to-conversation-events.md#members-removed) in [conversation update events](how-to/conversations/subscribe-to-conversation-events.md).|
+| channelCreated | `on_teams_channel_created` | You can override this method to handle a Teams channel being created. For more information, see [channel created](https://aka.ms/azure-bot-subscribe-to-conversation-events#channel-created) in [conversation update events](https://aka.ms/azure-bot-subscribe-to-conversation-events). |
+| channelDeleted | `on_teams_channel_deleted` | You can override this method to handle a Teams channel being deleted. For more information, see [channel deleted](https://aka.ms/azure-bot-subscribe-to-conversation-events#channel-deleted) in [conversation update events](https://aka.ms/azure-bot-subscribe-to-conversation-events).|
+| channelRenamed | `on_teams_channel_renamed` | You can override this method to handle a Teams channel being renamed. For more information, see [channel renamed](https://aka.ms/azure-bot-subscribe-to-conversation-events#channel-renamed) in [conversation update events](https://aka.ms/azure-bot-subscribe-to-conversation-events).|
+| teamRenamed | `on_teams_team_renamed` | `return Task.CompletedTask;` You can override this method to handle a Teams team being renamed. For more information, see [team renamed](https://aka.ms/azure-bot-subscribe-to-conversation-events#team-renamed) in [conversation update events](https://aka.ms/azure-bot-subscribe-to-conversation-events).|
+| MembersAdded | `on_teams_members_added` | This method calls the `OnMembersAddedAsync` method in `ActivityHandler`. You can override this method to handle members joining a team. For more information, see [team members added](https://aka.ms/azure-bot-subscribe-to-conversation-events#team-members-added) in [conversation update events](https://aka.ms/azure-bot-subscribe-to-conversation-events).|
+| MembersRemoved | `on_teams_members_removed` | This method calls the `OnMembersRemovedAsync` method in `ActivityHandler`. You can override this method to handle members leaving a team. For more information, see [team members removed](https://aka.ms/azure-bot-subscribe-to-conversation-events#team-members-removed) in [conversation update events](https://aka.ms/azure-bot-subscribe-to-conversation-events).|
#### Teams invoke activities
The list of Teams activity handlers called from the `on_invoke_activity` Teams a
| fileConsent/invoke | `on_teams_file_consent_decline` | This method is invoked when a file consent card is declined by the user. | | actionableMessage/executeAction | `on_teams_o365_connector_card_action` | This method is invoked when a connector card for Microsoft 365 Groups action activity is received from the connector. | | signin/verifyState | `on_teams_signin_verify_state` | This method is invoked when a signIn verify state activity is received from the connector. |
-| task/fetch | `on_teams_task_module_fetch` | This method can be overridden in a derived class to provide logic when a task module is fetched. |
-| task/submit | `on_teams_task_module_submit` | This method can be overridden in a derived class to provide logic when a task module is submitted. |
+| task/fetch | `on_teams_task_module_fetch` | You can override this method in a derived class to provide logic when a task module is fetched. |
+| task/submit | `on_teams_task_module_submit` | You can override this method in a derived class to provide logic when a task module is submitted. |
The invoke activities listed in this section are for conversational bots in Teams. The Bot Framework SDK also supports invoke activities specific to message extensions. For more information, see w[hat are message extensions](../messaging-extensions/what-are-messaging-extensions.md).
Now that you've familiarized yourself with bot activity handlers, let us see how
* [App manifest schema for Teams](../resources/schem) * [API reference for the Bot Framework Connector service](/azure/bot-service/rest-api/bot-framework-rest-connector-api-reference) * [Get Teams specific context for your bot](how-to/get-teams-context.md)
+* [Messages in bot conversations](how-to/conversations/conversation-messages.md)
platform Channel Messages With Rsc https://github.com/MicrosoftDocs/msteams-docs/commits/main/msteams-platform/bots/how-to/conversations/channel-messages-with-rsc.md
Title: Receive all conversation messages with RSC
-description: Enable bots to receive all channel messages without being @mentioned using RSC permissions. Read on webApplicationInfo or authorization section in manifest.
+description: Enable bots to receive all conversation messages without being @mentioned using RSC permissions. Read on webApplicationInfo or authorization section in manifest.
ms.localizationpriority: medium
The resource-specific consent (RSC) permissions model, originally developed for
## Enable bots to receive all channel or chat messages
-> [!NOTE]
->
-> The ability for bots to receive all messages in chats using `ChatMessage.Read.Chat` is available only in [public developer preview for Teams](../../../resources/dev-preview/developer-preview-intro.md).
- The `ChannelMessage.Read.Group` and `ChatMessage.Read.Chat` RSC permissions are being extended to bots. With user consent and app installation, these permissions: * Allow a specified graph application to get all messages in channels and chats, respectively. * Enable a bot defined in the app manifest to receive all conversations messages without being @mentioned in relevant contexts where the permissions apply.
+### Filtering at mention messages
+
+```csharp
+
+// When ChannelMessage.Read.Group or ChatMessage.Read.Chat RSC is in the app manifest, this method is called even when bot is not @mentioned.
+// This code snippet allows the bot to ignore all messages that do not @mention the bot.
+protected override async Task OnMessageActivityAsync(ITurnContext<IMessageActivity> turnContext, CancellationToken cancellationToken)
+{
+ // Ignore the message if bot was not mentioned.
+ // Remove this if block to process all messages received by the bot.
+ if (!turnContext.Activity.GetMentions().Any(mention => mention.Mentioned.Id.Equals(turnContext.Activity.Recipient.Id, StringComparison.OrdinalIgnoreCase)))
+ {
+ return;
+ }
+
+ // Sends an activity to the sender of the incoming activity.
+ await turnContext.SendActivityAsync(MessageFactory.Text("Using RSC the bot can receive messages across channels or chats in team without being @mentioned."));
+}
+
+```
+ > [!IMPORTANT] > > * Services that need access to all Teams message data must use the Graph APIs that provide access to archived data in channels and chats. > * Bots must use the `ChannelMessage.Read.Group` and `ChatMessage.Read.Chat` RSC permission appropriately to build and enhance engaging experience for users to pass the store approval. The app description must include how the bot uses the data it reads. > * The `ChannelMessage.Read.Group` and `ChatMessage.Read.Chat` RSC permission may not be used by bots to extract large amounts of customer data.
+> * The ability for bots to receive all messages in chats using `ChatMessage.Read.Chat` is available only in [public developer preview for Teams](../../../resources/dev-preview/developer-preview-intro.md) and is only enabled after a re-installation or new installation into a chat.
+> * After the RSC permissions are enabled, the bot continues to receive all messages even when the client switches out of public developer preview.
+> * If you have an app that's using the `ChatMessage.Read.Chat` RSC permission for Graph scenarios, then test the app following the steps in [sideload in a conversation](channel-messages-with-rsc.md?tabs=chat%2Cdotnet#sideload-in-a-conversation) and modify the app before the feature is [generally available](https://www.microsoft.com/en-us/microsoft-365/roadmap?filters=&searchterms=receive%2Call%2Cgroup%2Cchat%2Cmessages). If you don't want your bot to receive all chat messages, implement the following [code snippet](#filtering-at-mention-messages). If no action is taken, your bot will receive all messages after new installations.
## Update app manifest
The following steps guide you to sideload and validate bot that receives all cha
# [Chat messages](#tab/chat)
-The following steps guide you to sideload and validate bot that receives all chat messages without being @mentioned in a chat:
+The following steps guide you to sideload and validate bot that receives all chat messages in [public developer preview](../../../resources/dev-preview/developer-preview-intro.md) without being @mentioned in a chat:
+1. Switch the client to public developer preview (select **About** > **Developer preview**).
1. Select or create a group chat. 1. Select the ellipses &#x25CF;&#x25CF;&#x25CF; from the group chat. The dropdown menu appears. 1. Select **Manage apps** from the dropdown menu.
platform Conversation Messages https://github.com/MicrosoftDocs/msteams-docs/commits/main/msteams-platform/bots/how-to/conversations/conversation-messages.md
Title: Messages in bot conversations
-description: Learn how to send receive a message, suggested actions, notification, attachments, images, Adaptive Card and status error code responses.
+description: Learn how to send, receive, edit, undelete, and soft delete a message, suggested actions, notification, attachments, images, Adaptive Card and status error code responses.
ms.localizationpriority: medium
ms.localizationpriority: medium
# Messages in bot conversations
-Each message in a conversation is an `Activity` object of type `messageType: message`. When a user sends a message, Microsoft Teams posts the message to your bot. Teams sends a JSON object to your bot's messaging endpoint and Teams allows only one endpoint for messaging. Your bot examines the message to determine its type and responds accordingly.
+Each message in a conversation is an `Activity` object of type `messageType: message`. When a user sends a message, Microsoft Teams posts the message activity to your bot. Teams sends a JSON object to your bot's messaging endpoint and Teams allows only one endpoint for messaging. Your bot examines the message to determine its type and responds accordingly.
Basic conversations are handled through the Bot Framework connector, a single REST API. This API enables your bot to communicate with Teams and other channels. The Bot Builder SDK provides the following features:
For more information, see [user attribution for bot messages](/microsoftteams/pl
To receive a text message, use the `Text` property of an `Activity` object. In the bot's activity handler, use the turn context object's `Activity` to read a single message request.
-The following code shows an example of receiving a message:
+The following code shows an example of receiving a message activity:
-# [C#](#tab/dotnet)
+# [C#](#tab/dotnet1)
* [SDK reference](/dotnet/api/microsoft.bot.builder.activityhandler.onmessageactivityasync?view=botbuilder-dotnet-stable&preserve-view=true) * [Sample code reference](https://github.com/OfficeDev/Microsoft-Teams-Samples/blob/main/samples/meetings-token-app/csharp/Bots/TokenBot.cs#L52) ```csharp+ protected override async Task OnMessageActivityAsync(ITurnContext<IMessageActivity> turnContext, CancellationToken cancellationToken) { // Sends an activity to the sender of the incoming activity. await turnContext.SendActivityAsync(MessageFactory.Text($"Echo: {turnContext.Activity.Text}"), cancellationToken); }+ ```
-# [TypeScript](#tab/typescript)
+# [TypeScript](#tab/typescript1)
* [SDK reference](/javascript/api/botbuilder/teamsactivityhandler?view=botbuilder-ts-latest#botbuilder-teamsactivityhandler-onmessage&preserve-view=true) * [Sample code reference](https://github.com/OfficeDev/Microsoft-Teams-Samples/blob/main/samples/app-localization/nodejs/server/bot/botActivityHandler.js#L25) ```typescript+ export class MyBot extends TeamsActivityHandler { constructor() { super();
export class MyBot extends TeamsActivityHandler {
```
-# [Python](#tab/python)
+# [Python](#tab/python1)
+ * [SDK reference](/python/api/botbuilder-core/botbuilder.core.activityhandler?view=botbuilder-py-latest#botbuilder-core-activityhandler-on-message-activity&preserve-view=true) * [Sample code reference](https://github.com/OfficeDev/Microsoft-Teams-Samples/blob/main/samples/bot-conversation/python/bots/teams_conversation_bot.py#L103)
-<!-- Verify -->
```python async def on_message_activity(self, turn_context: TurnContext):
async def on_message_activity(self, turn_context: TurnContext):
```
-# [JSON](#tab/json)
+# [JSON](#tab/json1)
```json+ { "type": "message", "id": "1485983408511",
async def on_message_activity(self, turn_context: TurnContext):
}, "locale": "en-US" }+ ```
To send a text message, specify the string you want to send as an activity. In t
The following code shows an example of sending a message when a user is added to a conversation:
-# [C#](#tab/dotnet)
+# [C#](#tab/dotnet2)
* [SDK reference](/dotnet/api/microsoft.bot.builder.turncontext.sendactivityasync?view=botbuilder-dotnet-stable#microsoft-bot-builder-turncontext-sendactivityasync(microsoft-bot-schema-iactivity-system-threading-cancellationtoken)&preserve-view=true) * [Sample code reference](https://github.com/OfficeDev/Microsoft-Teams-Samples/blob/main/samples/bot-teams-authentication/csharp/Bots/TeamsBot.cs#L29) ```csharp+ protected override async Task OnMembersAddedAsync(IList<ChannelAccount> membersAdded, ITurnContext<IConversationUpdateActivity> turnContext, CancellationToken cancellationToken) { // Sends an activity to the sender of the incoming activity.
protected override async Task OnMembersAddedAsync(IList<ChannelAccount> membersA
```
-# [TypeScript](#tab/typescript)
+# [TypeScript](#tab/typescript2)
* [SDK reference](/javascript/api/botbuilder-core/turncontext?view=botbuilder-ts-latest#botbuilder-core-turncontext-sendactivity&preserve-view=true) * [Sample code reference](https://github.com/OfficeDev/Microsoft-Teams-Samples/blob/main/samples/bot-conversation/nodejs/bots/teamsConversationBot.js#L46) ```typescript+ this.onMembersAddedActivity(async (context, next) => { await Promise.all((context.activity.membersAdded || []).map(async (member) => { if (member.id !== context.activity.recipient.id) {
protected override async Task OnMembersAddedAsync(IList<ChannelAccount> membersA
```
-# [Python](#tab/python)
+# [Python](#tab/python2)
+ * [SDK reference](/python/api/botbuilder-core/botbuilder.core.turncontext?view=botbuilder-py-latest#botbuilder-core-turncontext-send-activity&preserve-view=true) * [Sample code reference](https://github.com/OfficeDev/Microsoft-Teams-Samples/blob/main/samples/bot-teams-authentication/python/bots/auth_bot.py#L33)
-<!-- Verify -->
- ```python+ async def on_members_added_activity( self, members_added: [ChannelAccount], turn_context: TurnContext ):
async def on_members_added_activity(
```
-# [JSON](#tab/json)
+# [JSON](#tab/json2)
```json+ { "type": "message", "from": {
async def on_members_added_activity(
Messages sent between users and bots include internal channel data within the message. This data allows the bot to communicate properly on that channel. The Bot Builder SDK allows you to modify the message structure.
+## Update message
+
+When you edit or undelete a message in a chat, the bot gets a notification of the edit message or undelete message event.
+
+To get an edit or undelete message event notification in a bot, you can override the following handlers:
+
+* For edit: `OnTeamsMessageEditAsync`
+* For undelete: `OnTeamsMessageUndeleteAsync`
+
+The following is an example of an edit message event notification when a sent message is edited:
+
+# [C#](#tab/csharp3)
+
+```csharp
+
+protected override async Task OnTeamsMessageEditAsync(ITurnContext<IMessageUpdateActivity> turnContext, CancellationToken cancellationToken)
+{
+var replyActivity = MessageFactory.Text("message is updated");
+await turnContext.SendActivityAsync(replyActivity, cancellationToken);
+}
+
+```
+
+# [JSON](#tab/json3)
+
+```json
+
+{
+"type":"messageUpdate",
+"timestamp":"2022-10-28T17:19:39.4615413Z",
+"localTimestamp":"2022-10-28T10:19:39.4615413-07:00",
+"id":"1666977568748",
+"channelId":"msteams",
+"serviceUrl":"https://canary.botapi.skype.com/amer/",
+"from": {
+ "id":"29:1BLjP9j3_PM4mubmQZsYPx7jDyLeLf_YVA9sVPV08KMAFMjJWB_EUGveb9EVDh9TslNp9qjnzEBy3kgw01Jf1Kg",
+ "name":"Mike Wilber",
+ "aadObjectId":"520e4d1e-2108-43ee-a092-46a9507c6200"
+},
+"conversation":{
+ "conversationType":"personal",
+ "tenantId":"528dbe3f-15e0-4e37-84a1-00cc305847dd","id":"a:1pweuGJ44RkB90tiJNQ_I6g3vyuP4CYA_f-v6f0Vd-Bs3Ce85C73Ah1y8TvyjESsTHWjjgw-gnsuIuCUOWkfOCq6qaUYsk2_-fj93XXXHUMAUzhFFvTnaCU7V4WiMqRPB"
+},
+"recipient":{
+ "id":"28:0d569679-gb4j-479a-b0d8-238b6e6b1149",
+ "name":"TestBot"
+},
+"entities":[
+ {
+ "locale":"en-US",
+ "country":"US",
+ "platform":"Web",
+ "timezone":"America/Los_Angeles",
+ "type":"clientInfo"
+ }
+],
+"channelData":{
+ "eventType":"editMessage",
+ "tenant":{"id":"528dbe3f-15e0-4e37-84a1-00cc305847dd"}
+},
+"locale":"en-US",
+"localTimezone":"America/Los_Angeles"
+}ΓÇ»
+
+```
+
+# [JavaScript](#tab/javascript3)
+
+You can either use **ΓÇïevent function registration** or **ΓÇïmethod override** method to get event notifications to handle the message updates using the Bot SDK:
+
+**ΓÇïEvent function registration**:
+
+```javascript
+
+this.onTeamsMessageEditEvent(async (context, next) => {
+ let editedMessage = context.activity.text;
+ await context.sendActivity(`The edited message is ${editedMessage}"`);
+ next();
+})
+
+```
+
+**ΓÇïMethod override**:
+
+```javascript
+
+async onTeamsMessageEdit(context) {
+ let editedMessage = context.activity.text;
+ await context.sendActivity(`The edited message is ${editedMessage}"`);
+}
+
+```
+++
+The following is an example of an undelete message event notification when a deleted message is restored:
+
+# [C#](#tab/csharp4)
+
+```csharp
+
+protected override async Task OnTeamsMessageUndeleteAsync(ITurnContext<IMessageUpdateActivity> turnContext, CancellationToken cancellationToken)
+{
+var replyActivity = MessageFactory.Text("message is undeleted");
+await turnContext.SendActivityAsync(replyActivity, cancellationToken);
+}
+
+```
+
+# [JSON](#tab/json4)
+
+```json
+
+{
+"type":"messageUpdate",
+"timestamp":"2022-10-28T17:19:39.4615413Z",
+"localTimestamp":"2022-10-28T10:19:39.4615413-07:00",
+"id":"1666977568748",
+"channelId":"msteams",
+"serviceUrl":"https://canary.botapi.skype.com/amer/",
+"from": {
+ "id":"29:1BLjP9j3_TM4mubmQZsYEo7jDyLeLf_YVA9sVPVO7KMAFMjJWB_EUGveb9EVDh9LgoNp9qjnzEBy4kgw83Jf1Kg",
+ "name":"Alex Wilber",
+ "aadObjectId":"976e4d1e-2108-43ee-a092-46a9507c5606"
+},
+"conversation":{
+ "conversationType":"personal",
+ "tenantId":"528dbe3f-15e0-4e37-84a1-00cc305847dd","id":"a:1tewuGJ44RkB90tiJNQ_I4q8vyuN5CYA_f-v6f0Vd-Bs3Ce85C73Ah1y8TvyjESsTHWjjgw-gnsuIuCUOWkfOCq6qaUYsk2_-fj93XXXHUMAUzhFFvTnaCU7V4WiMqXQL"
+},
+"recipient":{
+ "id":"28:0d469698-ab9d-479a-b0d8-758b6e6b1234",
+ "name":"Testbot"
+},
+"entities":[
+ {
+ "locale":"en-US",
+ "country":"US",
+ "platform":"Web",
+ "timezone":"America/Los_Angeles",
+ "type":"clientInfo"
+ }
+],
+"channelData":{
+ "eventType":"undeleteMessage",
+ "tenant":{"id":"528dbe3f-15e0-4e37-84a1-00cc305847dd"}
+},
+"locale":"en-US",
+"localTimezone":"America/Los_Angeles"
+}ΓÇ»
+
+```
+
+# [JavaScript](#tab/javascript4)
+
+You can either use **ΓÇïevent function registration** or **ΓÇïmethod override** method to get event notifications to handle the message updates using the Bot SDK:
+
+**ΓÇïEvent function registration**:
+
+```javascript
+
+this.onTeamsMessageUndeleteEvent(async (context, next) => {
+ let undeletedMessage = context.activity.text;
+ let messageId = context.activity.id;
+ await context.sendActivity(`Previously the message was deleted. After undeleting, the message is now: "${undeletedMessage}"`);
+ next();
+})
+
+```
+
+**ΓÇïMethod override**:
+
+```javascript
+
+async onTeamsMessageUndelete(context) {
+ let undeletedMessage = context.activity.text;
+ let messageId = context.activity.id;
+ await context.sendActivity(`Previously the message was deleted. After undeleting, the message is now: "${undeletedMessage}"`);
+}
+
+```
+++
+## Soft delete message
+
+When you soft delete a message in a chat, the bot gets a notification of the soft delete message event.
+
+To get a soft delete message event notification in a bot, you can override the `OnTeamsMessageSoftDeleteAsync` handler.
+
+The following is an example of a soft delete message event notification when a message is soft deleted:
+
+# [C#](#tab/csharp5)
+
+```csharp
+
+protected override async Task OnTeamsMessageSoftDeleteAsync(ITurnContext<IMessageDeleteActivity> turnContext, CancellationToken cancellationToken)
+{
+var replyActivity = MessageFactory.Text("message is soft deleted");
+await turnContext.SendActivityAsync(replyActivity, cancellationToken);
+}
+
+```
+
+# [JSON](#tab/json5)
+
+```json
+
+{
+"type":"messageDelete",
+"timestamp":"2022-10-28T17:19:43.1612052Z",
+"localTimestamp":"2022-10-28T10:19:43.1612052-07:00",
+"id":"1666977568748",
+"channelId":"msteams",
+"serviceUrl":"https://canary.botapi.skype.com/amer/",
+"from": {
+ "id":"29:1BLjP9j3_TM4mubmQZsYEo7jDyLeLf_YVA9sVPVO7KMAFMjJWB_EUGveb9EVDh9LgoNp9qjnzEBy4kgw83Jf1Kg",
+ "name":"Alex Wilber",
+ "aadObjectId":"976e4d1e-2108-43ee-a092-46a9507c5606"
+},
+"conversation":{
+ "conversationType":"personal",
+ "tenantId":"528dbe3f-15e0-4e37-84a1-00cc305847dd","id":"a:1tewuGJ44RkB90tiJNQ_I4q8vyuN5CYA_f-v6f0Vd-Bs3Ce85C73Ah1y8TvyjESsTHWjjgw-gnsuIuCUOWkfOCq6qaUYsk2_-fj93XXXHUMAUzhFFvTnaCU7V4WiMqXQL"
+},
+"recipient":{
+ "id":"28:0d469698-ab9d-479a-b0d8-758b6e6b1235",
+ "name":"Testbot"
+},
+"entities":[
+ {
+ "locale":"en-US",
+ "country":"US",
+ "platform":"Web",
+ "timezone":"America/Los_Angeles",
+ "type":"clientInfo"
+ }
+],
+"channelData":{
+ "eventType":"softDeleteMessage",
+ "tenant":{"id":"528dbe3f-15e0-4e37-84a1-00cc305847dd"}
+},
+"locale":"en-US",
+"localTimezone":"America/Los_Angeles"
+}ΓÇ»
+
+```
+
+# [JavaScript](#tab/javascript5)
+
+You can either use **ΓÇïevent function registration** or **ΓÇïmethod override** method to get event notifications to handle the message updates using the Bot SDK:
+
+**ΓÇïEvent function registration**:
+
+```javascript
+
+this.onTeamsMessageSoftDeleteEvent(async (context, next) => {
+ let messageId = context.activity.id;
+ await context.sendActivity(`The deleted message id is ${messageId}`);
+ next();
+})
+
+```
+
+**ΓÇïMethod override**:
+
+```javascript
+
+async onTeamsMessageSoftDelete(context) {
+ let messageId = context.activity.id;
+ await context.sendActivity(`The deleted message id is ${messageId}`);
+}
+
+```
+++ ## Send suggested actions The suggested actions enable your bot to present buttons that the user can select to provide input. Suggested actions enhance user experience by enabling the user to answer a question or make a choice with selection of a button, rather than typing a response with a keyboard.
this.onMessage(async (turnContext, next) => {
``` # [Python](#tab/python)+ [SDK reference](/python/api/botbuilder-core/botbuilder.core.teams?view=botbuilder-py-latest#botbuilder-core-teams-teams-notify-user&preserve-view=true) ```python
Ensure to handle these errors appropriately in your Teams app. The following tab
| Status code | Error code and message values | Description | Retry request | Developer action | |-|--|--|-|-|
-| 400 | **Code**: `Bad Argument` <br/> **Message**: *scenario specific | Invalid request payload provided by the bot. See error message for specific details. | No | Re-evaluate request payload for errors. Check returned error message for details. |
+| 400 | **Code**: `Bad Argument` <br/> **Message**: *scenario specific | Invalid request payload provided by the bot. See error message for specific details. | No | Reevaluate request payload for errors. Check returned error message for details. |
| 401 | **Code**: `BotNotRegistered` <br/> **Message**: No registration found for this bot. | The registration for this bot wasn't found. | No | Verify the bot ID and password. Ensure that the bot ID (AAD ID) is registered in the Teams Developer Portal or via Azure bot channel registration in Azure with 'Teams' channel enabled.| | 403 | **Code**: `BotDisabledByAdmin` <br/> **Message**: The tenant admin disabled this bot | Tenant admin has blocked interactions between user and the bot app. Tenant admin needs to allow the app for the user inside of app policies. For more information, see [app policies](/microsoftteams/app-policies). | No | Stop posting to conversation until interaction with bot is explicitly initiated by a user in the conversation indicating that the bot is no longer blocked. |
-| 403 | **Code**: `BotNotInConversationRoster` <br/> **Message**: The bot isn't part of the conversation roster. | The bot isn't part of the conversation. App needs to be reinstalled in conversation. | No | Before attempting to send another conversation request, wait for an [`installationUpdate`](~/bots/how-to/conversations/subscribe-to-conversation-events.md#install-update-event) event, which indicates that the bot has been re-added.|
+| 403 | **Code**: `BotNotInConversationRoster` <br/> **Message**: The bot isn't part of the conversation roster. | The bot isn't part of the conversation. App needs to be reinstalled in conversation. | No | Before attempting to send another conversation request, wait for an [`installationUpdate`](~/bots/how-to/conversations/subscribe-to-conversation-events.md#install-update-event) event, which indicates that the bot has been added again.|
| 403 | **Code**: `ConversationBlockedByUser` <br/> **Message**: User blocked the conversation with the bot. | User has blocked the bot in personal chat or a channel through moderation settings. | No | Delete the conversation from cache. Stop attempting to post to conversations until interaction with bot is explicitly initiated by a user in the conversation, indicating that the bot is no longer blocked. |
-| 403 |**Code**: `InvalidBotApiHost` <br/> **Message**: Invalid bot api host. For GCC tenants please call `https://smba.infra.gcc.teams.microsoft.com`.|The bot called the public API endpoint for a conversation that belongs to a GCC tenant.| No | Update the service URL for the conversation to `https://smba.infra.gcc.teams.microsoft.com` and retry the request.|
+| 403 |**Code**: `InvalidBotApiHost` <br/> **Message**: Invalid bot api host. For GCC tenants, please call `https://smba.infra.gcc.teams.microsoft.com`.|The bot called the public API endpoint for a conversation that belongs to a GCC tenant.| No | Update the service URL for the conversation to `https://smba.infra.gcc.teams.microsoft.com` and retry the request.|
| 403 | **Code**: `NotEnoughPermissions` <br/> **Message**: *scenario specific | Bot doesn't have required permissions to perform the requested action. | No | Determine the required action from the error message. | | 404 | **Code**: `ActivityNotFoundInConversation` <br/> **Message**: Conversation not found. | The message ID provided couldn't be found in the conversation. Message doesn't exist or it has been deleted. | No | Check if message ID sent is an expected value. Remove the ID if it was cached. | | 404 | **Code**: `ConversationNotFound` <br/> **Message**: Conversation not found. | Conversation wasn't found as it doesn't exist or has been deleted. | No | Check if conversation ID sent is an expected value. Remove the ID if it was cached. |
The general retry guidance for each status code is listed in the following table
|-|--| | 403 | Retry by calling the GCC API `https://smba.infra.gcc.teams.microsoft.com` for `InvalidBotApiHost`.| | 412 | Retry using exponential backoff. |
-| 429 | Retry using `Retry-After` header to determine wait time in seconds and in between requests, if available. Otherwise, retry using exponential backoff with thread ID, if possible. |
+| 429 | Retry using `Retry-After` header to determine the wait time in seconds and in between requests, if available. Otherwise, retry using exponential backoff with thread ID, if possible. |
| 502 | Retry using exponential backoff. | | 503 | Retry using exponential backoff. | | 504 | Retry using exponential backoff. |
The general retry guidance for each status code is listed in the following table
|-|--|--|-|--|--| | Teams conversation bot | Messaging and conversation event handling. | [View](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/bot-conversation/nodejs) | [View](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/bot-conversation/csharp) | [View](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/bot-conversation/python) | NA | | Teams app localization | Teams app localization using bot and tab. | [View](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/app-localization/nodejs) | NA | NA | [View](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/app-localization/csharp) |
+| Update and delete message | Sample app shows how to get a update and delete event notification in your bot. | [View]() | NA | NA | [View]() |
## Next step
The general retry guidance for each status code is listed in the following table
* [Send and receive files through the bot](~/bots/how-to/bots-filesv4.md) * [Send tenant ID and conversation ID to the request headers of the bot](~/bots/how-to/conversations/request-headers-of-the-bot.md) * [Localize your app](../../../concepts/build-and-test/apps-localization.md)
+* [Bot activity handlers](../../bot-basics.md)
platform Tab Sso Graph Api https://github.com/MicrosoftDocs/msteams-docs/commits/main/msteams-platform/tabs/how-to/authentication/tab-sso-graph-api.md
Title: Extend tab app with Microsoft Graph permissions
-description: Configure additional permissions and scopes with Microsoft Graph for enabling Single sign-on (SSO).
+description: Configure additional permissions and scopes, get access token with Microsoft Graph to enable single sign-on (SSO).
ms.localizationpriority: high
-keywords: teams authentication tabs Microsoft Azure Active Directory (Azure AD) Graph API Delegated permission access token scope
# Extend tab app with Microsoft Graph permissions and scopes
You can configure additional Graph scopes in Azure AD for your app. These are de
2. Select **Manage** > **API permissions** from the left pane.
- :::image type="content" source="../../../assets/images/authentication/teams-sso-tabs/api-permission-menu.png" alt-text="App permissions menu option.":::
+ :::image type="content" source="../../../assets/images/authentication/teams-sso-tabs/api-permission-menu.png" alt-text="The screenshot shows the app permissions menu option.":::
The **API permissions** page appears. 3. Select **+ Add a permission** to add Microsoft Graph API permissions.
- :::image type="content" source="../../../assets/images/authentication/teams-sso-tabs/app-permission.png" alt-text="App permissions page.":::
+ :::image type="content" source="../../../assets/images/authentication/teams-sso-tabs/app-permission.png" alt-text="The screenshot shows the app permissions page.":::
The **Request API permissions** page appears. 4. Select **Microsoft Graph**.
- :::image type="content" source="../../../assets/images/authentication/teams-sso-tabs/request-api-permission.png" alt-text="Request API permissions page.":::
+ :::image type="content" source="../../../assets/images/authentication/teams-sso-tabs/request-api-permission.png" alt-text="The screenshot shows shows the request API permissions page.":::
The options for Graph permissions display. 5. Select **Delegated permissions** to view the list of permissions.
- :::image type="content" source="../../../assets/images/authentication/teams-sso-tabs/delegated-permission.png" alt-text="Delegated permissions.":::
+ :::image type="content" source="../../../assets/images/authentication/teams-sso-tabs/delegated-permission.png" alt-text="The screenshot shows the delegated permissions.":::
6. Select relevant permissions for your app, and then select **Add permissions**.
- :::image type="content" source="../../../assets/images/authentication/teams-sso-tabs/select-permission.png" alt-text="Select permissions.":::
+ :::image type="content" source="../../../assets/images/authentication/teams-sso-tabs/select-permission.png" alt-text="The screenshot shows the add permissions option.":::
You can also enter the permission name in the search box to find it.
- A message pops up on the browser stating that the permissions were updated.
+ A message appears on the browser stating that the permissions were updated.
- :::image type="content" source="../../../assets/images/authentication/teams-sso-tabs/updated-permission-msg.png" alt-text="Permissions updated message.":::
+ :::image type="content" source="../../../assets/images/authentication/teams-sso-tabs/updated-permission-msg.png" alt-text="The screenshot shows the message that appears for the updated permissions.":::
The added permissions are displayed in the **API permissions** page.
- :::image type="content" source="../../../assets/images/authentication/teams-sso-tabs/configured-permissions.png" alt-text="API permissions are configured.":::
+ :::image type="content" source="../../../assets/images/authentication/teams-sso-tabs/configured-permissions.png" alt-text="The screenshot shows an example of the API permissions, which are configured.":::
You've configured your app with Microsoft Graph permissions.
Depending on the platform or device where you want to target your app, additiona
> [!NOTE] > > - If your tab app hasn't been granted IT admin consent, app users have to provide consent the first time they use your app on a different platform.
-> - Implicit grant is not required if SSO is enabled on a tab app.
+> - Implicit grant isn't required if SSO is enabled on a tab app.
You can configure authentication for multiple platforms as long as the URL is unique.
You can configure authentication for multiple platforms as long as the URL is un
1. Select **Manage** > **Authentication** from the left pane.
- :::image type="content" source="../../../assets/images/authentication/teams-sso-tabs/azure-portal-platform.png" alt-text="Authenticate for platforms":::
+ :::image type="content" source="../../../assets/images/authentication/teams-sso-tabs/azure-portal-platform.png" alt-text="The screenshot for authenticating platforms.":::
The **Platform configurations** page appears. 1. Select **+ Add a platform**.
- :::image type="content" source="../../../assets/images/authentication/teams-sso-tabs/add-platform.png" alt-text="Add a platforms":::
+ :::image type="content" source="../../../assets/images/authentication/teams-sso-tabs/add-platform.png" alt-text="The screenshot shows the options to add add a platform.":::
The **Configure platforms** page appears.
-1. Select the platform that you want to configure for your tab app. You can choose the platform type from web or SPA.
+1. Select the platform that you want to configure for your tab app. You can choose the platform type from **web** or **Single-page application**.
- :::image type="content" source="../../../assets/images/authentication/teams-sso-tabs/configure-platform.png" alt-text="Select web platform":::
+ :::image type="content" source="../../../assets/images/authentication/teams-sso-tabs/configure-platform.png" alt-text="The screenshot for selecting web platform.":::
You can configure multiple platforms for a particular platform type. Ensure that the redirect URI is unique for every platform you configure.
You can configure authentication for multiple platforms as long as the URL is un
1. Enter the configuration details for the platform.
- :::image type="content" source="../../../assets/images/authentication/teams-sso-tabs/config-web-platform.png" alt-text="Configure web platform":::
+ :::image type="content" source="../../../assets/images/authentication/teams-sso-tabs/config-web-platform.png" alt-text="The screenshot for configuring web platform.":::
1. Enter the redirect URI. The URI should be unique. 2. Enter the front-channel logout URL.
You can configure authentication for multiple platforms as long as the URL is un
## Acquire access token for MS Graph
-You'll need to acquire access token for Microsoft Graph. You can do so by using Azure AD OBO flow.
+You'll need to acquire access token for Microsoft Graph. You can do so by using Azure AD on-behalf-of (OBO) flow.
-The current implementation for SSO grants consent for only user-level permissions that are not usable for making Graph calls. To get the permissions (scopes) needed to make a Graph call, SSO apps must implement a custom web service to exchange the token received from the Teams JavaScript library for a token that includes the needed scopes. You can use Microsoft Authentication Library (MSAL) for fetching the token from the client side.
+The current implementation for SSO grants consent for only user-level permissions that aren't usable for making Graph calls. To get the permissions (scopes) needed to make a Graph call, SSO apps must implement a custom web service to exchange the token received from the Teams JavaScript library for a token that includes the needed scopes. You can use Microsoft Authentication Library (MSAL) for fetching the token from the client side.
After you've configured Graph permissions in Azure AD: -- [Configure your client-side code to fetch access token using MSAL](#configure-code-to-fetch-access-token-using-msal)-- [Pass the access token to server-side code](#pass-the-access-token-to-server-side-code)
+1. [Get the token ID from Teams client](#get-the-token-id-from-teams-client)
+1. [Exchange the token ID with the server-side token](#exchange-the-token-id-with-the-server-side-token)
-### Configure code to fetch access token using MSAL
+### Get the token ID from Teams client
-The following code provides an example of OBO flow to fetch access token from the Teams client using MSAL.
+The following is an example for calling token ID from Teams client:
+
+```csharp
+microsoftTeams.authentication.getAuthToken().then((result) => {
+ //result contains the id token
+ console.log(result);
+ })
+```
+
+### Exchange the token ID with the server-side token
+
+The following is an example of OBO flow to fetch access token from the Teams client using MSAL:
### [C#](#tab/dotnet)
IConfidentialClientApplication app = ConfidentialClientApplicationBuilder.Create
-### Pass the access token to server-side code
- If you need to access Microsoft Graph data, configure your server-side code to: 1. Validate the access token. For more information, see [Validate the access token](tab-sso-code.md#validate-the-access-token).
If you need to access Microsoft Graph data, configure your server-side code to:
> [!IMPORTANT] > As a best practice for security, always use the server-side code to make Microsoft Graph calls, or other calls that require passing an access token. Never return the OBO token to the client to enable the client to make direct calls to Microsoft Graph. This helps protect the token from being intercepted or leaked.
+## Code sample
+
+| **Sample name** | **Description** | **C#** | **Node.js** |
+| | | | |
+| Tabs Azure AD SSO | Microsoft Teams sample app for tabs Azure AD SSO, which uses OBO flow to call Graph APIs. | [View](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/69c76fded29d7ae0fde49841d4ec9af7597ceedd/samples/tab-sso/csharp) | [View](https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/69c76fded29d7ae0fde49841d4ec9af7597ceedd/samples/tab-sso/nodejs)|
+ ## Known limitations Tenant admin consent: A simple way of [consenting on behalf of an organization as a tenant admin](/azure/active-directory/manage-apps/consent-and-permissions-overview#admin-consent) is by getting [consent from admin](/azure/active-directory/manage-apps/grant-admin-consent).
platform Whats New https://github.com/MicrosoftDocs/msteams-docs/commits/main/msteams-platform/whats-new.md
Discover Microsoft Teams platform features that are generally available (GA). Yo
Teams platform features that are available to all app developers.
-**2022 December**
+**2023 January**
-* ***December 8, 2022***: [Introducing Teams developer documentation FAQs](teams-faq.md)
-* ***December 7, 2022***: [Introducing notification bot in Teams](bots/how-to/conversations/notification-bot-in-teams.md)
-* ***December 7, 2022***: [Introducing command bot in Teams](bots/how-to/conversations/command-bot-in-teams.md)
+***January 27, 2023***: [Introducing update and soft delete event notifications in bot](bots/how-to/conversations/conversation-messages.md#update-message)
:::column-end::: :::row-end:::
Teams platform features that are available to all app developers.
| **Date** | **Update** | **Find here** | | -- | | -|
+| 08/12/2022 | Introducing Teams developer documentation FAQs. | [Teams developer documentation FAQs](teams-faq.md) |
+| 07/12/2022 | Introducing notification bot in Teams. | Build bots > Bot conversations > [Notification bot in Teams](bots/how-to/conversations/notification-bot-in-teams.md) |
+| 07/12/2022 | Introducing command bot in Teams. | Build bots > Bot conversations > [Command bot in Teams](bots/how-to/conversations/command-bot-in-teams.md) |
| 29/11/2022 | Introducing plan analytics for your Teams app. | Plan your app > Plan analytics for your Teams app > [Overview](concepts/design/overview-analytics.md) | | 23/11/2022 | Updated integrate location capabilities. | Integrate device capabilities > [Integrate location capabilities](concepts/device-capabilities/location-capability.md) | | 22/11/2022 | Revamped enable SSO for your bot and message extension app. | Add authentication > Enable SSO for your Teams app > Enable SSO for your bot and message extension app > [Overview](bots/how-to/authentication/bot-sso-overview.md) |