Nov 22 2023 09:26 PM
How can we forward adaptive cards in teams. Is there any easy way out?
One method which I found was using Graph API. Following the below link with Example 3 : Send a message containing cards :-
https://learn.microsoft.com/en-us/graph/api/chatmessage-post?view=graph-rest-1.0&tabs=javascript#exa...
But it has html content, how to add json content to it. Please can anyone help with this?
Nov 22 2023 09:55 PM
Nov 26 2023 09:26 PM
Hi @Janhvi - Could you please let us know if you have any further queries?
Nov 27 2023 09:06 AM
@Prasad_Das-MSFT
This webhook seems to be compatible only with channels. But our requirement is to forward adaptive card in a personal chat.
Nov 28 2023 05:35 AM
@Janhvi - As you have already mentioned using this API we can send adaptive card to personal chat/group chat or channel.
POST https://graph.microsoft.com/v1.0/chats/{chat-id}/messages
{
"subject": null,
"body": {
"contentType": "html",
"content": "<attachment id=\"74d20c7f34aa4a7fb74e2b30004247c5\"></attachment>"
},
"attachments": [
{
"id": "74d20c7f34aa4a7fb74e2b30004247c5",
"contentType": "application/vnd.microsoft.card.thumbnail",
"contentUrl": null,
"content": "{\r\n \"title\": \"This is an example of posting a card\",\r\n \"subtitle\": \"<h3>This is the subtitle</h3>\",\r\n \"text\": \"Here is some body text. <br>\\r\\nAnd a <a href=\\\"http://microsoft.com/\\\">hyperlink</a>. <br>\\r\\nAnd below that is some buttons:\",\r\n \"buttons\": [\r\n {\r\n \"type\": \"messageBack\",\r\n \"title\": \"Login to FakeBot\",\r\n \"text\": \"login\",\r\n \"displayText\": \"login\",\r\n \"value\": \"login\"\r\n }\r\n ]\r\n}",
"name": null,
"thumbnailUrl": null
}
]
}
In the above example the request body is already in JSON format. However, it seems like the "content" field in the "attachments" array is a stringified JSON.
As it has html content, you are interested in something easier. So, you can use Power Automate/Flow to send adaptive card in personal chat or channel following below document.
Create flows that post adaptive cards to Microsoft Teams - Power Automate | Microsoft Learn
Thanks,
Prasad Das
------------------------------------------------------------------------------------------
If the response is helpful, please click "**Mark as Best Response**" and like it. You can share your feedback via Microsoft Teams Developer Feedback link. Click here to escalate.
Nov 28 2023 11:27 AM
{
"body": {
"contentType": "html",
"content": "<attachment id=\"74d20c7f34aa4a7fb74e2b30004247c5\"></attachment>"
},
"attachments": [
{
"id": "74d20c7f34aa4a7fb74e2b30004247c5",
"contentType": "application/vnd.microsoft.card.adaptive",
"contentUrl": null,
"content": "{ \"type\": \"AdaptiveCard\", \"body\": [ { \"type\": \"Container\", \"items\": [ { \"type\": \"Image\", \"url\": \"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBwgHBgkIBwgKCgkLDRYPDQwMDRsUFRAWIB0iIiAdHx8kKDQsJCYxJx8fLT0tMTU3Ojo6Iys/RD84QzQ5OjcBCgoKDQwNGg8PGjclHyU3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3N//AABEIAIIAYgMBIgACEQEDEQH/xAAcAAABBQEBAQAAAAAAAAAAAAAAAwQFBgcIAgH/xABEEAABAwMCAgUJBAcGBwAAAAABAgMEAAUREiEGMRMiQVFhBxQyQlJxgZGhIzOx8BVDYmOCwdEkJnKSotIXdIOTssLi/8QAGQEBAAMBAQAAAAAAAAAAAAAAAAECBAMF/8QAIhEAAgICAQUBAQEAAAAAAAAAAAECEQMhEhMiMUFRYXEE/9oADAMBAAIRAxEAPwDaQNIKUHKT6Su6jA06D6HtUDGMo9D1hRtpyfuewUAHrYC9gn0fGjJJ1qGFjknvoOBjpOXqAfn3UHIPXP2g5HsAoBpdLnDs8NydPfQy2nY6u09wHMnwqhueVBSn1CFaVGP7bzuFH4AbfM1Q+NeJXOIr6670ivM2VFEdGdgketjvPOkWX2WoeoKQ2oDYk4rPPI7qJrx4VVyNDn+VOOzFabi29apJyXW3V4CR3ggb5+lTHDXH1svikRZP9ik8kpWrKVnwVisKXNDs9IdUFdQpCknx7a8reMdzZ3IBzy2qVkd7IlijWjqU9bClbKHId9BJzrA6/s1SfJjxMq82zzSasqmRwOjUT6SOz3kGrtvn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eJBZGjKwhi/W2PcrCm2Okj7uUwNKgOaQoYUg16/Q0S5LHSG7WKZtrSy8pTJP7JwpGPgD4VoqOFbI0VmNb2oxWcq82y1qPeQnAJrw5wvAWnSXJISeaQ5jPxxn61TpMssqooh4Wfjg/wB6JhA7FtNq/BNMZ9sX0K2n77raWkpVqjtJyPepYx8q0hHB1iQcqhFzvDr7iwfgVYpdjhiwR162bJbUL9sRUavnjNOj7J62qMOPD9oyf7yIHh00f/fRXQAgxAMCKx/2xRV+m/pTqfg4ooorqcgooooAooooAooooAooooAooooAooooD//Z\", \"size\": \"medium\", \"height\": \"auto\" }, { \"type\": \"TextBlock\", \"text\": \"Welcome to Adaptive Cards!\", \"size\": \"large\", \"weight\": \"bolder\" }, { \"type\": \"TextBlock\", \"text\": \"Click the button below for more information.\", \"wrap\": true } ] }, { \"type\": \"ActionSet\", \"actions\": [ { \"type\": \"Action.OpenUrl\", \"title\": \"Learn More\", \"url\": \"https://adaptivecards.io\" } ] } ], \"speak\": \"Welcome to Adaptive Cards! Click the button below for more information.\", \"$schema\": \"http://adaptivecards.io/schemas/adaptive-card.json\", \"version\": \"1.2\"}",
"name": null,
"thumbnailUrl": null
}
]
}
POST /chats/{chat-id}/messages
ON using the above API we are able to forward this type of adaptive card to a particular user.
But the content is not exactly the same format we use for adaptive card. Can you please tell how to create this format out of normal adaptive cards json data?
Nov 29 2023 10:55 PM
@ray2408 - There is no tool available for this type of conversion. We have to manually do that.
For example, if this is your adaptive card JSON:
{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.2",
"speak": "Welcome to Adaptive Cards! Click the button below for more information.",
"body": [
{
"type": "Container",
"items": [
{
"type": "TextBlock",
"text": "Welcome to Adaptive Cards!",
"size": "large",
"weight": "bolder"
},
{
"type": "TextBlock",
"text": "Click the button below for more information.",
"wrap": true
}
]
},
{
"type": "ActionSet",
"actions": [
{
"type": "Action.OpenUrl",
"title": "Learn More",
"url": "https://adaptivecards.io"
}
]
}
]
}
the converted format would be as below:
{\"type\": \"AdaptiveCard\", \"body\": [ { \"type\": \"Container\", \"items\": [ { \"type\": \"TextBlock\", \"text\": \"Welcome to Adaptive Cards!\", \"size\": \"large\", \"weight\": \"bolder\" }, { \"type\": \"TextBlock\", \"text\": \"Click the button below for more information.\", \"wrap\": true } ] }, { \"type\": \"ActionSet\", \"actions\": [ { \"type\": \"Action.OpenUrl\", \"title\": \"Learn More\", \"url\": \"
https://adaptivecards.io\"
} ] } ], \"speak\": \"Welcome to Adaptive Cards! Click the button below for more information.\", \"$schema\": \"
http://adaptivecards.io/schemas/adaptive-card.json\"
, \"version\": \"1.2\"}
Nov 30 2023 08:28 PM
Dec 01 2023 03:36 AM - edited Dec 01 2023 03:43 AM
@ray2408 - There isn't any way to forward an adaptive card from one chat to another.
However, you can send adaptive card in chat or channel using bot.
Adaptive Cards for Bot Developers - Adaptive Cards | Microsoft Learn
Sample ref: Microsoft-Teams-Samples/samples/bot-adaptive-card-actions at main · OfficeDev/Microsoft-Teams-Sample...
as well as via Power Automate as mentioned in earlier conversations.
Create flows that post adaptive cards to Microsoft Teams - Power Automate | Microsoft Learn