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!