Search code examples
botframeworkmicrosoft-teamsmicrosoft-graph-teams

Unable to receive channel message without mentioning MS Teams bot


I followed the documentation where I added the webApplicationInfo inside manifest.json to include RSC permissions. However, I still do not receive any message activity when the bot is not mentioned in the message.

"webApplicationInfo": {
    "id": "<i have updated app id here>",
    "resource": "https://AnyString",
    "applicationPermissions": [
      "ChannelMessage.Read.Group"
    ]
  }

Below is my code to echo the message:

protected override async Task OnMessageActivityAsync(ITurnContext<IMessageActivity> turnContext, CancellationToken cancellationToken)
        {
            await turnContext.SendActivityAsync(MessageFactory.Text($"Echo: {turnContext.Activity.Text}"), cancellationToken);
        }

I have checked against permissionGrant restful API (https://graph.microsoft.com/v1.0/groups/{groupid}/permissionGrants) and it includes "ChannelMessage.Read.Group"

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#permissionGrants",
    "value": [
        {
            "id": "<id ....>",
            "deletedDateTime": null,
            "clientId": "<client id ...>",
            "clientAppId": "<client app id ...>",
            "resourceAppId": "<resource app id ...>",
            "permissionType": "Application",
            "permission": "ChannelMessage.Read.Group"
        }
    ]
}

Here is a link to screenshot of the current situation (bot still only receives the message when bot is @mentioned.)

Thanks in advance!


Solution

  • In teams channel to send messages to bot you need to @mention the Botname. It is by design.