Hi.
I created a chatbot using Power Virtual Agents and added it to a Teams channel. When someone posts a message on the Teams channel, I want to reply to that message using Power Automate. This Power Automate message should be able to @mention and call the chatbot. Is there a way to accomplish this?
Thanks in advance.
Solved! Go to Solution.
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
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"
}
}
}
]
}
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/
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
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"
}
}
}
]
}
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/
Keep up to date with current events and community announcements in the Power Virtual Agents community.
A great place where you can stay up to date with community calls and interact with the speakers.
User | Count |
---|---|
5 | |
1 | |
1 | |
1 | |
1 |