Receive all channel messages with RSC

The resource-specific consent (RSC) permissions model, originally developed for Teams Graph APIs, is extended to bot scenarios.

Using RSC, you can now request team owners to consent for a bot to receive user messages across standard channels in a team without being @mentioned. This capability is enabled by specifying the ChannelMessage.Read.Group permission in the manifest of an RSC enabled Teams app. After configuration, team owners can grant consent during the app installation process.

For more information about enabling RSC for your app, see resource-specific consent in Teams.

Enable bots to receive all channel messages

The ChannelMessage.Read.Group RSC permission is extended to bots. With user consent, this permission allows graph applications to get all messages in a conversation and bots to receive all channel messages without being @mentioned.

Note

  • Services that need access to all Teams message data must use the Graph APIs that also provide access to archived data in channels and chats.
  • Bots must use the ChannelMessage.Read.Group RSC permission appropriately to build and enhance engaging experience for users in the team or they will not pass the store approval. The app description must include how the bot uses the data it reads.
  • The ChannelMessage.Read.Group RSC permission may not be used by bots as a way to extract large amounts of customer data.

Update app manifest

For your bot to receive all channel messages, RSC must be configured in the Teams app manifest with the ChannelMessage.Read.Group permission specified in the webApplicationInfo property.

Screenshot of app manifest update.

The following is an example of the webApplicationInfo object:

  • id: Your Microsoft Azure Active Directory (Azure AD) app ID. This can be the same as your bot ID.
  • resource: Any string. This field has no operation in RSC, but must be added and have a value to avoid error response.
  • applicationPermissions: RSC permissions for your app with ChannelMessage.Read.Group must be specified. For more information, see resource-specific permissions.

The following code provides an example of the app manifest:

"webApplicationInfo": {
  "id": "XXxxXXXXX-XxXX-xXXX-XXxx-XXXXXXXxxxXX",
  "resource": "https://AnyString",
  "applicationPermissions": [
    "ChannelMessage.Read.Group"
  ]
}

Sideload in a team

To sideload in a team to test, whether all channel messages in a team with RSC are received without being @mentioned:

  1. Select or create a team.

  2. Select the ellipses ●●● from the left pane. The drop-down menu appears.

  3. Select Manage team from the drop-down menu. The details appear.

    Screenshot of Managing team option in Teams application.

  4. Select Apps. Multiple apps appear.

  5. Select Upload a custom app from the lower right corner.

    Screenshot of upload a custom app option.

  6. Select the app package from the Open dialog box.

  7. Select Open.

    Screenshot of the open dialog box to select the app package.

  8. Select Add from the app details pop-up, to add the bot to your selected team.

    Screenshot of the Add button to add a bot to a team.

  9. Select a channel and enter a message in the channel for your bot.

    The bot receives the message without being @mentioned.

    Screenshot of a bot receiving message in a channel.

Code snippets

The following code provides an example of RSC permissions:


// Handle when a message is addressed to the bot. 
// When rsc is enabled the method will be called even when bot is addressed without being @mentioned
protected override async Task OnMessageActivityAsync(ITurnContext<IMessageActivity> turnContext, CancellationToken cancellationToken)
{
  await turnContext.SendActivityAsync(MessageFactory.Text("Using RSC the bot can receive messages across channels in team without being @mentioned."));
}

Code sample

Sample name Description C# Node.js
Channel messages with RSC permissions Microsoft Teams sample app demonstrating on how a bot can receive all channel messages with RSC without being @mentioned. View View

See also