MS Teams Graph API @Mention a Bot

Deleted
Not applicable

We're doing some work with a bot that's been added as a member to a Teams channel, and are attempting to send a message to the bot through the at_mention function to have the bot take some action. Below is the full JSON request that we're posting to the Messages API. The post appears to at_mention the bot, but the bot doesn't respond. Have tested this with multiple bots in this channel, and doesn't appear that the problem is specific to the particular bot we're working with. 

 

Any help would be greatly appreciated!

 

 
{
  "body": {
    "contentType": "html",
    "content": "<div><div><at id=\"0\">Cisco Webex Meetings</at> site test.webex.com</div>\n</div>"
    },
  "mentions": [
    {
      "id": 0,
      "mentionText": "Cisco Webex Meetings",
      "mentioned": {
        "application": {
          "displayName": "Cisco Webex Meetings",
          "id": "<bot-id>",
          "applicationIdentityType": "bot"
        }
      }
    }
  ]
}
 
photo.jpg
2 Replies

Facing the same issue, did you find any solution?

So this does work but the catch I found is that you have to know what the botId was in the manifest of the bot, and there's no way that I've seen to be able to query that out from the msgraph, nor is that necessarily displayed as "External app ID" in the teams admin UI.

 

The workaround I've seen for that is to manually add the bot to a channel or chat, and then query back the graph representation like querying for /chats/{chat-id}/messages and then seeing what ID it's using for the bot. Once you know the botId then the at-mention would look like this:

 

{
  "body": {
    "contentType": "html",
    "content": "<at id=\"0\">Polly</at> Color? Purple, White"
  },
  "mentions": [
      {
        "id": 0,
        "mentionText": "Polly",
        "mentioned": {
          "application": {
            "displayName": "Polly",
            "id": "817c2506-de4a-4795-971e-371ea75a03ed",
            "applicationIdentityType": "bot"
          }
        }
      }
    ]
}