Skip to main content
Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Answered

[SOLVED] Need help creating adaptive card with dynamic fact sets

Like (0) ShareShare
ReportReport
Posted on 15 Nov 2022 16:31:43 by 9

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:

cbckr_0-1668528687066.png

Initialize ArrayForFactSet

cbckr_1-1668528732548.png

Post adaptive card in chat or channel
cbckr_2-1668528779941.png

Resulting adaptive card

cbckr_3-1668528814811.png

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.

cbckr_4-1668529007891.png

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!  

  • v-qiaqi@microsoft.com Profile Picture
    on 17 Nov 2022 at 06:27:53
    Re: Need help creating adaptive card with dynamic fact sets

    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.

  • Verified answer
    c-bckr Profile Picture
    9 on 16 Nov 2022 at 12:28:18
    Re: Need help creating adaptive card with dynamic fact sets

    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 {}

     

    cbckr_1-1668601614892.png

     

    The adaptive card should now render correctly.

     

     

     

     

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 2

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 2

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 2