Hello,
i want to use the Logic App Designer to send some teams notifications using adaptive cards.
Depending on the input, several fact sets are included in the adaptive card. Since there is no support for binding, i need to create these fact sets manually and include them in the adaptive card payload.
I was able to do this using a flow like this:
Initialize ArrayForFactSet
Post adaptive card in chat or channel
Resulting adaptive card
Resulting adaptive card json
{
"type": "AdaptiveCard",
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.4",
"body": [
{
"type": "Container",
"items": [
{"type":"FactSet","facts":[{"title":"DisplayName","value":"User A"},{"title":"UserPrincipalName","value":" User-a@contoso.com"}]},{"type":"FactSet","facts":[{"title":"DisplayName","value":"User B"},{"title":"UserPrincipalName","value":" user-b@contoso.com"}]},
]
}
]
}
The Problem:
My problem is that i want to reuse the adaptive card in different actions. To do this i have created the adaptive card json in a compose action and used the output of the compose action in the "Post adaptive card to chat or channel" action.
Apparently this wont work, since the fact sets are insert as a string and not as an object.
Note the escaped characters and line breaks.
Resulting adaptive card
{
"type": "AdaptiveCard",
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.4",
"body": [
{
"type": "Container",
"items": [
"{\"type\":\"FactSet\",\"facts\":[{\"title\":\"DisplayName\",\"value\":\"User A\"},{\"title\":\"UserPrincipalName\",\"value\":\" User-a@contoso.com\"}]},{\"type\":\"FactSet\",\"facts\":[{\"title\":\"DisplayName\",\"value\":\"User B\"},{\"title\":\"UserPrincipalName\",\"value\":\" user-b@contoso.com\"}]},"
]
}
]
}
I have also tried to append my fact sets to an array variable and use this in the compose action.
This problem is the array is enclosed in brackets and i cant use this inside the "items" array of a adaptive card container.
Using the array, the adaptive card looks like this
{
"type": "AdaptiveCard",
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.4",
"body": [
{
"type": "Container",
"items": [
[
{
"type": "FactSet",
"facts": [
{
"title": "DisplayName",
"value": "User A"
},
{
"title": "UserPrincipalName",
"value": " User-a@contoso.com"
}
]
},
{
"type": "FactSet",
"facts": [
{
"title": "DisplayName",
"value": "User B"
},
{
"title": "UserPrincipalName",
"value": " user-b@contoso.com"
}
]
},
{
"type": "FactSet",
"facts": [
{
"title": "DisplayName",
"value": "User A"
},
{
"title": "UserPrincipalName",
"value": " User-a@contoso.com"
}
]
},
{
"type": "FactSet",
"facts": [
{
"title": "DisplayName",
"value": "User B"
},
{
"title": "UserPrincipalName",
"value": " user-b@contoso.com"
}
]
}
]
]
}
]
}
Does anyone have an idea on how to create the adaptive card payload in a compose action?
Or how i could enter a string variable in a compose action without it being interpreted as string?
Or alternatively, is there a way to remove the bracktes from an array variable?
I hope I have explained my problem clearly, if not just ask.
Thanks a lot!
Hi @c-bckr,
Glad that you have reso,ved your problem.
Could you please mark your reply as an answer to help more user?
Thanks for your cooperation.
I have found a solution:
1. Append all fact sets to an array variable
2. Create a string from the array using a compose action and cut the [ ] at the beginning and end of the string
substring(string(variables('ArrayForFactSet')), 1, sub(length(string(variables('ArrayForFactSet'))),2))
The output of the compose action should look like this:
{"type":"FactSet","facts":[{"title":"DisplayName","value":"User A"},{"title":"UserPrincipalName","value":" User-a@contoso.com"}]},{"type":"FactSet","facts":[{"title":"DisplayName","value":"User B"},{"title":"UserPrincipalName","value":" user-b@contoso.com"}]}​
3. Create a Compose action for the adaptive card payload, but without the { } at the begin and end
Example:
"type": "AdaptiveCard",
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.4",
"body": [
{
"type": "Container",
"items": [
@{outputs('Compose')}
]
}
]
4. Create a "Post adaptive card to chat or channel" action and insert the output of the last compose action as adaptive card payload. But enclose the compose action output in {}
The adaptive card should now render correctly.
Michael E. Gernaey
497
Super User 2025 Season 2
David_MA
436
Super User 2025 Season 2
Riyaz_riz11
244
Super User 2025 Season 2