cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
brentfraser
Frequent Visitor

Mention Person (user) and Channel in the same Adaptive Card

Hello all,

 

I am using a power automate flow to post to a channel and in the message I want to be a able to mention both a user, and also a channel.

 

Now I have both working but in two methods in two posts. The one post, the @mention user is working but I can't get the channel mention to work. The other post, I can get the @channel mention to work but not the user.

 

For the user mention, I am using 'Post an adaptive card in a chat or channel' with this code:

{
   "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "type": "AdaptiveCard",
    "version": "1.2",
    "msTeams": {
"width": "full",
},
    "body": [
{
"type": "Image",
"url": "https://sjrb.sharepoint.com/:i:/r/teams/Enablement/Shared%20Documents/General/happy-anniversary-banner.png?csf=1&web=1&e=FBeneX"
},
        {
            "type": "TextBlock",
            "text": "Happy Anniversary @{items('Apply_to_each_2')?['Employee_x0020_Name/DisplayName']} - @{items('Apply_to_each_2')?['Employee_x0020_Name/JobTitle']}",
            "id": "Title",
            "horizontalAlignment": "Left",
            "size": "Large",
            "weight": "Bolder",
            "color": "Accent"
        },
        {
            "type": "TextBlock",
            "text": "We want to recognize @{outputs('Get_an_@mention_token_for_a_user')?['body/atMention']} for being a part of the Shaw Family for @{outputs('Compose_2')} years. Congratulations on this great milestone! 🎉",
            "wrap": true
        },
 {
            "type": "TextBlock",
            "text": "_The future has big things in store for you, but we are so glad you are here with us in the present. Happy work anniversary!_",
            "spacing": "Medium",
            "horizontalAlignment": "Left",
            "size": "Medium",
            "fontStyle": "true",
"wrap": true,
            "color": "Accent"
        },
 ],
}

For the mention of the channel, I am using 'Send an HTTP Request' with this code:

 

{
  "body": {
    "contentType": "html",
    "content": "<at id=\"0\">ESTN Community</at> This is a channel alert! 🔔"
  },
  "mentions": [
    {
      "id": 0,
      "mentionText": "ESTN Community",
      "mentioned": {
        "conversation": {
          "id": "@{outputs('ChannelID')}",
          "displayName": "ESTN Community",
          "@odata.type": "microsoft.graph.teamworkConversationIdentity",
          "conversationIdentityType": "channel"
        }
      }
    }
  ]
}

 

Is there any way to get both the user and channel mention in the same post? Ultimately I'd like to use the Adaptive card because I have an image I am using as a banner.

 

I have tried using an <a href> to see if it works, and also an <at>Channel</at> and nothing works.

 

Thanks for the help!

Brent

 

 

 

 

 

2 REPLIES 2
Expiscornovus
Super User
Super User

Hi @brentfraser,

 

Recently @TomaszPoszytek has written a nice overview blog about this.

 

One of his examples actually has a user and channel mention in the same adaptive card:

https://poszytek.eu/en/microsoft-en/office-365-en/powerautomate-en/how-to-mention-tags-users-channel...

 

In your setup that would be probably something like below.

You still need to adjust the User name & User AAD Id part with your dynamic content values.

 

{
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "type": "AdaptiveCard",
    "version": "1.4",
    "body": [
        {
            "type": "TextBlock",
            "id": "MentionTextBlock",
            "text": "Fun with mentions thanks to Tomasz!",
            "weight": "Bolder",
            "size": "Medium"
        },
        {
            "type": "TextBlock",
            "text": "This is user mention. Hi: <at>USER NAME</at>!",
            "size": "Medium"
        },
        {
            "type": "TextBlock",
            "text": "This is channel mention. <at>ESTN Community</at>!",
            "size": "Medium"
        }
    ],
    "msteams": {
        "entities": [
            {
                "type": "mention",
                "text": "<at>USER NAME</at>",
                "mentioned": {
                    "id": "8:orgid:USER AAD ID",
                    "name": "USER NAME"
                }
            },
            {
                "type": "mention",
                "text": "<at>ESTN Community</at>",
                "mentioned": {
                    "id": "@{outputs('ChannelID')}",
                    "displayName": "ESTN Community",
                    "conversationIdentityType": "channel"
                }
            }
        ]
    }
}

 

Hello there @Expiscornovus 

 

Thank you for the code. I tried it out and I can mention the person/user, but the channel still does not come up.

 

I get this:

 

Fun with mentions thanks to Tomasz!

 

This is user mention. Hi: USER NAME!

 

This is channel mention. !

 

I am not sure why the channel mention doesn't even appear. The mentioning of the user work perfectly though. The channel ID comes across as 19:0d3d9732709e4810906c2358d30e2f6b@thread.tacv2 so that looks correct.

 

Any thoughts?

 

Thanks again for the point in the right direction. I think we are close.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Super User 2 - 2022 Congratulations 768x460.png

Welcome Super Users

The Super User program for 2022- Season 2 has kicked off!

Users online (4,000)