Forum Discussion
Deleted
Jun 14, 2019MS Teams Graph API @Mention a Bot
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. Be...
dragade
Sep 26, 2023Copper Contributor
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"
}
}
}
]
}