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.

8 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
  • Paul R Casillo

    Hey Tomasz are you able to add this trigger to a solution? I can’t seem to get it to work.

    October 2, 2020 at 4:00 pm Reply
    • Tomasz Poszytek

      Haven’t tried it. But you can do it from the other side – in a solution click to add new flow and then use the trigger.

      October 10, 2020 at 4:16 pm Reply
  • Soraya Villaverde Lopez

    Is there any way to use dynamic content in the adaptive card of the trigger? I would like to have the selected message as part of the text that can be updated in the adaptive card, but i cannot the way to do it.

    October 26, 2022 at 8:31 am Reply
    • Tomasz Poszytek

      You can’t refer in a card to message context. However message details (such as ID) will be submitted along with the card data.

      December 14, 2022 at 10:12 am Reply
  • Tony Stephens

    Nice article Tomaz! I’ve been looking for a way to get an External person’s email address from the “Selected Message” so I can create a Teams Quick action to send a generic email. Do you know if that’s possible? I’ve tried “Get Message Details” but it wants a “Message Type” and there is no option for a private chat. Any suggestions?

    Thanks again for the article – very helpful!
    Tony.

    June 19, 2023 at 2:39 am Reply
    • Tomasz Poszytek

      As far I know this works only for messages in Teams channels.

      June 29, 2023 at 10:46 am Reply

Post a Comment

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