Mention users and place redirect button at the same card

Leonardo Maffei da Silva 0 Reputation points
2023-01-20T21:44:42.3266667+00:00

I have the following MS teams card:

User's image

which is described by JSON

{
	"@type": "AdaptiveCard",
	"@context": "http://schema.org/extensions",
	"themeColor": "0076D7",
	"summary": "Summary",
	"sections": [
		{
			"facts": [
				{
					"name": "People to Mention",
					"value": "[Mary](user@main.com) <at>0</at>"
				}
			],
			"markdown": "true"
		}
	],
	"potentialAction": [
		{
			"@type": "OpenUri",
			"name": "Go to Another MS teams channel",
			"targets": [
				{
					"os": "default",
					"uri": "https://teams.microsoft.com/l/channel/...."
				}
			]
		}
	],
	"msteams": {
		"entities": [
			{
				"type": "mention",
				"text": "<at>0</at>",
				"mentioned": {
					"id": "user@mail.comr",
					"name": "John"
				}
			}
		]
	}
}

The problem is I am not able to mention people. I could manage to effectively mention people with the JSON below


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

And the result was

enter image description here

As you could have notice, the problem seems to be that {@type: "Adaptive"} and {"type": "message"} behave differently so that I wasn't able to combine what I nedd from both of them into one Card.

Any suugestions on how to mention users and place the "go to button" in the same card?

Microsoft Teams
Microsoft Teams
A Microsoft customizable chat-based workspace.
9,074 questions
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,592 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. SanthiSwaroopNaikBukke-4908 595 Reputation points
    2023-01-20T21:58:22.4833333+00:00
    To mention users and add a "go to" button in the same card in Microsoft Teams, you can use the Adaptive Card feature. Adaptive Cards allow you to create interactive cards that include various elements, such as text, images, and buttons.
    
    Here's an example of how you can create an Adaptive Card that mentions users and includes a "go to" button:
    
    Copy code
    {
        "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
        "type": "AdaptiveCard",
        "version": "1.0",
        "body": [
            {
                "type": "TextBlock",
                "text": "Hello, @user1 @user2"
            },
            {
                "type": "TextBlock",
                "text": "Please click the button to go to the link"
            },
            {
                "type": "ActionSet",
                "actions": [
                    {
                        "type": "Action.OpenUrl",
                        "title": "Go to link",
                        "url": "https://www.example.com"
                    }
                ]
            }
        ]
    }
    In this example, you can see that the card includes a "TextBlock" element for the message that mentions the users with the "@" symbol, and it also includes an "ActionSet" element that contains an "Action.OpenUrl" button with a title of "Go to link" and a specified URL to open.
    
    You can also use the Microsoft Teams SDK to create the card and send it to a specific channel or user.
    
    You can also use the Microsoft Teams SDK to create the card and send it to
    
    0 comments No comments