How to add carousal effect adaptive cards in Bot Framework Composer response for an array object result?

Problem statement

I had a requirement to show the following data returned from the JSON output in the Bot Framework Composer.

[
  {
    "name": "XYZ Clinic",
    "address": "6546 Some Steet",
    "city": "SomeCity",
    "state": "SomeState",
    "zip": "99999",
    "phone": "999-888-7777 ",
    "ApptTypeName": "PRIMARY CARE",
    "newWaitTime": 23.0
  },
  …
]

Solution

In the send response action here are the Adaptive card related response texts for the above array object. You would call the ResultActivity(objArrayResult).

#ResultThumbnailCard(resultObj)
[ThumbnailCard
    title = ${resultObj.name}
    subtitle = ${resultObj.ApptTypeName} ${resultObj.newWaitTime} days
    text = ${resultObj.address}, ${resultObj.city}, ${resultObj.state} - ${resultObj.zip} 
    image = https://picsum.photos/200/200
    buttons = tel://${resultObj.phone}
]

#ResultActivity(resultArrObj)
[Activity
name = An Example Name
Attachments = ${ foreach ( resultArrObj, x, ResultThumbnailCard(x) ) }  
AttachmentLayout = carousel
]

About Pankaj

I am a Developer and my linked profile is https://www.linkedin.com/in/pankajsurti/
This entry was posted in Uncategorized. Bookmark the permalink.

1 Response to How to add carousal effect adaptive cards in Bot Framework Composer response for an array object result?

  1. Noel King says:

    Hey Pankaj,

    Everything worked perfectly when I hardcoded the json by just setting a property for the array but I do you get it from the PVA to the composer? I am trying to use the search_for_users_(v2) flow to make a global address book with your help ;). I am having issues passing the json from the flow back to the pva and then to the composer.

    Let me know!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s