Re: Call a Teams Chatbot via a Power Automate Flow
Hi @Himashi,
First of all great question, very interesting scenario 🙂
You could use the Graph API and the Reply to a message in a channel method. In that request you can reply with an at-mention to the bot and add a topic trigger text.
Below is a short example.
1. Add a When a new channel message is added trigger action
![whenanewchannelmessageisadded02.png whenanewchannelmessageisadded02.png](/_api/msdyn_richtextfiles%28DB89A2ED-6F71-40E2-91CF-52151EEC5E90%29/msdyn_imageblob/$value?size=full)
2. Add a Send an HTTP request action (Office 365 Groups Connector)
Use the following URI & the POST method
https://graph.microsoft.com/v1.0/teams/@{triggerOutputs()?['body/channelIdentity']['teamId']}/channels/@{triggerOutputs()?['body/channelIdentity']['channelId']}/messages/@{triggerOutputs()?['body/id']}/replies
Use the json below for the body.
Replace the variables with your values for the topic trigger phrase, bot name & bot app id.
{
"body": {
"contentType": "html",
"content": "<div><div><at id=\"0\">@{variables('BotName')}</at> @{variables('PVATopicTrigger')}</div></div>"
},
"mentions": [
{
"id": 0,
"mentionText": "@{variables('BotName')}",
"mentioned": {
"device": null,
"user": null,
"conversation": null,
"tag": null,
"application": {
"id": "@{variables('BotAppId')}",
"displayName": "@{variables('BotName')}",
"applicationIdentityType": "bot"
}
}
}
]
}
![atmentionbotviagraphapi.png atmentionbotviagraphapi.png](/_api/msdyn_richtextfiles%288E19B814-FE91-46E8-8E0D-4B7364673BA8%29/msdyn_imageblob/$value?size=full)
Btw, I have also written a blog about this approach with a bit more details:
https://www.expiscornovus.com/2022/06/10/mention-a-bot-with-a-flow/