Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bot Framework Compose: Dynamic multiple choice action (from API)

I'm building a bot with bot framework composer (V2)

I want to create a multiple choice action, with choices that I get from a API call.

Api Choices

[
    {
        "id": 0,
        "name": "One",
        "active": true
    },
    {
        "id": 1,
        "name": "Two",
        "active": true
    },
    {
        "id": 2,
        "name": "Three",
        "active": true
    },
    {
        "id": 3,
        "name": "Four",
        "active": true
    },
    {
        "id": 4,
        "name": "Five",
        "active": true
    }
]

How do I bind this choices in the multiple choice action? enter image description here

like image 923
Gerald Hughes Avatar asked Mar 19 '26 18:03

Gerald Hughes


1 Answers

I assume that you are able to call API and got the data in array format, suppose it got stored in dialog.response.

So what you need to do is,

  1. Add a For each item: Loop and configure it as shown in screenshot.loop configuration
  2. Next, add Edit an Array Property in the loop and configure it as shown in screenshot Edit an Array Property configuration
  3. Now, at the end, you need to add Multi-Choice(that you have already added) and give dialog.choices in Array of choices Array of choices

I have tested this flow till the bot sent card with multiple choice. Output

like image 158
Hunaid Hanfee-MSFT Avatar answered Mar 22 '26 06:03

Hunaid Hanfee-MSFT