Notifying users on Teams channel using adaptive cards in incoming webhooks

HG 0 Reputation points
2023-03-21T13:58:43.2966667+00:00

Hi!

I am using adaptive cards in incoming webhooks to automatically post when there is a new activity in our CRM system, and I want to mention specific users in the adaptive cards as shown here (https://learn.microsoft.com/en-us/microsoftteams/platform/task-modules-and-cards/cards/cards-format?tabs=adaptive-md%2Cdesktop%2Cconnector-html)..) As I am unknowledgeable in coding, I have been struggling to figure out how to make it work.. It will be appreciated if I could get some support on this.

The following JSON code is what I currently have for posting adaptive cards in Teams channel:

{     
"@type": "MessageCard",    
"@context": "http://schema.org/extensions",     
"themeColor": "78A22E",     
"summary": "New quote",     
"sections": [{
         "activityTitle": "${Quotes.Quote Owner} created a new quote",
         "facts": [{
             "name": "Quote Owner",
             "value": "${Quotes.Quote Owner}"
        }, {
             "name": "Division",
             "value": "${Quotes.Division}"
        }, {
             "name": "Account",
             "value": "${Accounts.Account Name}"
        }, {
             "name": "Subject",
             "value": "${Quotes.Subject}"
        }],
         "markdown": true
    }],
     "potentialAction": [{
         "@type": "OpenUri",
         "name": "Open",
         "targets": [{
             "os": "default",
             "uri": "URL${Quotes.Quote Id}"
        }]
     }]
 }
Microsoft Teams | Development
Microsoft Teams | Microsoft Teams for business | Other
{count} votes

1 answer

Sort by: Most helpful
  1. Prasad-MSFT 9,061 Reputation points Microsoft External Staff Moderator
    2023-03-22T07:46:11.8966667+00:00

    Incoming webhooks supports user mention in Adaptive Cards with the Azure AD Object ID and UPN.
    Example:

    {
        "type": "message",
        "attachments": [
            {
            "contentType": "application/vnd.microsoft.card.adaptive",
            "content": {
                "type": "AdaptiveCard",
                "body": [
                    {
                        "type": "TextBlock",
                        "size": "Medium",
                        "weight": "Bolder",
                        "text": "Sample Adaptive Card with User Mention"
                    },
                    {
                        "type": "TextBlock",
                        "text": "Hi <at>Adele UPN</at>, <at>Adele Azure AD</at>"
                    }
                ],
                "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
                "version": "1.0",
                "msteams": {
                    "entities": [
                        {
                            "type": "mention",
                            "text": "<at>Adele UPN</at>",
                            "mentioned": {
                              "id": "******@contoso.onmicrosoft.com",
                              "name": "Adele Vance"
                            }
                          },
                          {
                            "type": "mention",
                            "text": "<at>Adele Azure AD</at>",
                            "mentioned": {
                              "id": "87d349ed-44d7-43e1-9a83-5f2406dee5bd",
                              "name": "Adele Vance"
                            }
                          }
                    ]
                }
            }
        }]
    }
    
    

    For more details please refer: https://learn.microsoft.com/en-us/microsoftteams/platform/task-modules-and-cards/cards/cards-format?tabs=adaptive-md%2Cdesktop%2Cconnector-html#user-mention-in-incoming-webhook-with-adaptive-cards

    Thanks, 

    Prasad Das

    ************************************************************************* 

    If the response is helpful, please click "Accept Answer" and upvote it. You can share your feedback via Microsoft Teams Developer Feedback link. Click here to escalate. 
     


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.