loading...

Use adaptive cards with mention in Microsoft Teams

kenakamu profile image Kenichiro Nakamura ・2 min read

Adaptive Card is very flexible way to create rich card which I can send to many platform. One of the platform is Microsoft Teams.

What's more interesting is that Power Automate can send Adaptive Card now.

Use adaptive cards in Microsoft Teams

One thing I couldn't figure out was how to "mention" people. There is a document Mention support within Adaptive cards and it says

The mention object inside of an msteams property in the card content, which includes the Teams user id of the user being mentioned

{
  "contentType": "application/vnd.microsoft.card.adaptive",
  "content": {
    "type": "AdaptiveCard",
    "body": [
      {
        "type": "TextBlock",
        "text": "Hi <at>John Doe</at>"
      }
    ],
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "version": "1.0",
    "msteams": {
      "entities": [
        {
          "type": "mention",
          "text": "<at>John Doe</at>",
          "mentioned": {
            "id": "29:123124124124",
            "name": "John Doe"
          }
        }
      ]
    }
  }
}

The question was how to get the Teams user id.

I found an thread discussing this at Ms Teams @ Mentions in adaptive cards and at the end, it seems like I just need to use 8:orgid:{org-ID-of-the-user} format like below.

"entities": [
  {
    "type": "mention",
    "text": "<at>Kenichiro Nakamura</at>",
    "mentioned": {
        "id": "8:orgid:{org-ID-of-the-user}",
        "name": "Kenichiro Nakamura"
     }
  }
]

Now I can simply use any way to get the user id, such as Graph Explorer.

If the user id is f9e0c5cb-f4ee-43d4-91e2-63524d1bacd9, then the message I send in Power Automate looks like:

{
   "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", 
    "type": "AdaptiveCard",
    "version": "1.0",
    "body": [
      {
        "type": "TextBlock",
        "text": "Hi <at>Kenichiro Nakamura</at>"
      }
    ],
    "msteams": {
      "entities": [
        {
          "type": "mention",
          "text": "<at>Kenichiro Nakamura</at>",
          "mentioned": {
            "id": "8:orgid:f9e0c5cb-f4ee-43d4-91e2-63524d1bacd9",
            "name": "Kenichiro Nakamura"
          }
        }
      ]
    }
}

The result is:
Alt Text

Cool :)

Discussion

pic
Editor guide
 

Hello i managed to to mention someone but that person is not alerted and when i hover over his name nothing happens as opposed to a manual mention. Any suggestions?