question

GoldmanChase-8834 avatar image
0 Votes"
GoldmanChase-8834 asked Meghana-MSFT answered

@Mentions in Adaptive Card Won't Notify Mentioned Users

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!

office-teams-app-dev
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @GoldmanChase-8834

Our forum is mainly focused on the general issue of Microsoft Teams troubleshooting. According to your description, your issue is more related to development, which is not in our support scope. I will remove teams tag and add teams-app-dev tag. Thanks for your understanding and patience!

0 Votes 0 ·

1 Answer

Meghana-MSFT avatar image
0 Votes"
Meghana-MSFT answered Meghana-MSFT edited

@GoldmanChase-8834

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





5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.