Top
Power Automate + Adaptive Cards + Microsoft Teams

For a selected message – new trigger in Power Automate


In the beginning of July Microsoft has added two new triggers for Power Automate to integrate better with Microsoft Teams: For a selected message and When a new team member is added. In this post I will go you in details through the first one from them.

Watch it in action!

The triggers

Both will help you to increase governance in Microsoft Teams. For a selected message will let you to manage actions for a specific message, selected by a user. When a new team member is added on the other hand will let you to act once a team owner adds new members and eg. prepare flow sending welcome message containing rules, etc.

For a selected message

Important! Today this trigger works only with flows that are created in Default environment.

What you will notice once you use that trigger is the new Adaptive Cards designer built into the action. You can craft your message directly from Power Automate designer:

The card you will built is going then to be displayed to the user, who selects the message and chooses that specific flow to be triggered.

How does this trigger work?

Once you design the card and the flow, and save it, navigate to Microsoft Teams. Then hover over a message in a channel or a private conversation. You will notice that a small ellipsis icon (…) appears (1). Expand message options and at the bottom of the menu hover on “More actions” (2). There you will find all the flows that are created with the “For selected message” trigger (3).

Note: the flows’ labels visible under “More actions” menu are displaying names of the flows. So when creating them be sure you give them descriptive and rather short names.

What next?

Once user clicks flow’s name, it will popup the Adaptive Card created inside trigger action:

After submitting the card, flow will be triggered where you can actually design whatever you need. The most important is the scope of data returned by the trigger:

{
   "entity":{
      "teamsFlowRunContext":{
         "MessagePayload":{
            "Id":"[MESSAGE ID]",
            "From":{
               "Application":"[APP ID OF THE MESSAGE]",
               "Conversation":"[CONVERSATION ID OF THE MESSAGE]",
               "Device":"[DEVICE DETAILS, IF PRESENT]",
               "User":{
                  "DisplayName":"John Researcher",
                  "Id":"e4e6b40f-f698-403e-bc8e-252a2d52f22c"
               }
            },
            "Body":{
               "ContentType":"html",
               "Content":"[HTML CONTENTS OF THE MESSAGE]",
               "PlainText":"[PLAIN-TEXT CONTENTS OF THE MESSAGE]"
            },
            "Subject":null,
            "LinkToMessage":"[ABSOLUTE LINK TO THE MESSAGE]"
         },
         "Id":"[REQUEST ID]",
         "Value":"[REQUEST VALUE]",
         "ChannelData":{
            "EventType":"[ID OF THE EVENT IF AVAILABLE]",
            "Team":{
               "Id":"[TEAM ID]",
               "Name":"[TEAM NAME]"
            },
            "Tenant":{
               "Id":"[TENANT ID]"
            },
            "Channel":{
               "Id":"[CHANNEL ID]",
               "Name":"[CHANNEL NAME]"
            },
            "Notification":"[NOTIFICATION]"
         },
         "From":{
            "Id":"[REQUESTER ID]",
            "Name":"[REQUESTER DISPLAY NAME]",
            "Role":"[REQUESTER ROLE]",
            "AadObjectId":"[REQUESTER AAD ID]",
            "Properties":"[REQUESTER ADDITIONAL PROPERTIES]"
         },
         "Conversation":{
            "Id":"[CONVERSATION ID]",
            "Name":"[CONVERSATION NAME]",
            "IsGroup":true
         },
         "Locale":"en-US",
         "CommandContext":"message"
      },
      "cardOutputs":{
         "[ELEMENT ID]":"[ELEMENT VALUE]"
      }
   }
}

This data helps to identify precisely the selected message and its location. Plus, it contains all the data from the designed Adaptive Card. Remember, to define IDs for each control you want to get the value from:

Important! The defined control’s ID MUST be UNIQUE!

One of the really important returned values is “LinkToMessage” – that one, once clicked, navigate to the selected in request message, highlighting it with yellow background so that user knows which message the request is about:

How do you like it? If you have any questions/ remarks please leave them in the comments below! Thanks!


Tomasz Poszytek

Hi, I am Tomasz. I am expert in the field of process automation and business solutions' building using Power Platform. I am Microsoft MVP and Nintex vTE.

2 Comments
  • rf

    Thanks for your videos! very helpful as i am currently automatign integration for our bot to teams 🙂

    just have one question > i dont seem to have the “for a selected message” as one of my triggers.

    July 8, 2020 at 5:07 am Reply
    • Tomasz Poszytek

      This functionality is just rolling out. Should arrive somewhere this month to every tenant.

      July 9, 2020 at 11:52 am Reply

Post a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.