Skip to main content

Notifications

Building Copilot Studio Chatbots in Microsoft T...
Answered

Call a Teams Chatbot via a Power Automate Flow

Posted on by 7

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. 

  • bruna_rs Profile Picture
    bruna_rs 2 on at
    Re: Call a Teams Chatbot via a Power Automate Flow

    @Expiscornovus Could you please post this last solution?

     

  • Expiscornovus Profile Picture
    Expiscornovus 1,667 on at
    Re: Call a Teams Chatbot via a Power Automate Flow

    Hi @ryeee,

     

    The action has changed and is now limited to only the groups resource. In this example we are not using that type of resource, that's why you are getting that error. You can replace this action by a HTTP action instead.

     

    That action is however part of a premium connecter and you would also need to register an app in Entra Id for the Oath authentication.

  • ryeee Profile Picture
    ryeee 3 on at
    Re: Call a Teams Chatbot via a Power Automate Flow

    @Expiscornovus 
    Thanks for the solution presented. However, it appears that this is not working as of this writing.
    I read your vlog and tried replicating the flow but was getting this error message.
    URI path is not a valid Graph endpoint, path is neither absolute nor relative or resource/object is not supported for this connector.
    I tested the uri through graph explorer and it works but does not with the http connecter in powerautomate.

  • Himashi Profile Picture
    Himashi 7 on at
    Re: Call a Teams Chatbot via a Power Automate Flow

    @Expiscornovus Great and detailed solution. Thank you very much! 

  • Verified answer
    Expiscornovus Profile Picture
    Expiscornovus 1,667 on at
    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

     

    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

     

    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/

     

Helpful resources

Quick Links

Exciting News for Copilot Studio Communi…

Get ready to experience a whole new level of engagement with the Copilot Studio…

Celebrating the May Super User of the…

LaurensM is an exceptional contributor to the Power Platform Community…

Check out the Copilot Studio Cookbook…

We are excited to announce our new Copilot Cookbook Gallery in the Community…

Leaderboard

#1
renatoromao Profile Picture

renatoromao 6,459

#2
Pstork1 Profile Picture

Pstork1 1,954

#3
Expiscornovus Profile Picture

Expiscornovus 1,667

Featured topics