@Mentions in Adaptive Card Won't Notify Mentioned Users

Goldman, Chase 1 Reputation point
2021-07-30T15:25:05.033+00:00

Hi,

I'm trying to send adaptive cards to a microsoft teams channel using the Python requests module. I have a JSON file with the adaptive card contents inside of it and making a requests.post() to my webhook URL for the teams channel.

I'm trying to incorporate the @mention feature inside of my adaptive card. Whenever I send the card with this @mention, it changes the font and color of the person's name I am trying to mention but doesn't actually notify them that they have been mentioned or populate their information when you hover over their name.

Here's an example of the JSON I am sending with my post request:

{
  "type":"message",
  "attachments":[
    {
      "contentType": "application/vnd.microsoft.card.adaptive",
      "content": {
        "type": "AdaptiveCard",
        "body": [
          {
            "type": "TextBlock",
            "text": "Hi <at>Lastname, Firstname</at>"
          },
          {
            "type": "TextBlock",
            "text": "Hi <at>Lastname, Firstname</at>"
          }
        ],
        "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
        "version": "1.0",
        "msteams": {
          "entities": [
           {
              "type": "mention",
              "text": "<at>Lastname, Firstname</at>",
              "mentioned": {
                "id": "8:orgid:xxx",
                "name": "xxx@xxx.com"
              }
            }
            },
            {
              "type": "mention",
              "text": "<at>Lastname, Firstname</at>",
              "mentioned": {
                "id": "8:orgid:xxx",
                "name": "xxx@xxx.com"
              }
            }
          ]
        }
      }
    }
  ]
}

Removed names, emails, and org ID's for privacy purposes.

Here's the code which I'm using to send the JSON to our channel:

   headers = {
        'Content-Type': 'application/json',
    }

    with open("adaptive_card.json", "r") as infile:

      adaptive_card_json = infile.read()

    data = json.dumps(adaptive_card_json)

    response = requests.post(self.webhook_url, headers=headers, data=data)

    print(response.text)

Thanks for your help!

Microsoft Teams Development
Microsoft Teams Development
Microsoft Teams: A Microsoft customizable chat-based workspace.Development: The process of researching, productizing, and refining new or existing technologies.
2,920 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Meghana-MSFT 3,801 Reputation points Microsoft Vendor
    2021-08-10T08:09:50.52+00:00

    @Goldman, Chase

    We tried it from our end and it worked for us.

    { type: "AdaptiveCard", $schema: "http://adaptivecards.io/schemas/adaptive-card.json", version: "1.0", body: [ { type: "TextBlock", size: "Medium", weight: "Bolder", text: "Hi <at>MOD Administrator</at> This is new feature in Adaptive Card version 1.2 Please test..." } ], msteams: { entities: [ { type: "mention", text: "<at>MOD Administrator</at>", mentioned: { id: "29:15fREhoUuf6vVCOuaJYVH-AB6QXXX", name: "MOD Administrator" } } ] }}

    Note : ID and Name can be fetched from the activity as follows

    from: {
    id: '29:15fREhoUuf6vVCOuaJYVH-AB6QXXX',
    name: 'MOD Administrator',
    aadObjectId: 'XXXX'
    }

    Giving a reference that will help - mention-support-within-adaptive-cards-v12

    0 comments No comments