3

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

Gerald Hughes
  • 5,771
  • 20
  • 73
  • 131

1 Answers1

3

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

Hunaid Hanfee-MSFT
  • 836
  • 1
  • 3
  • 8
  • Great, very useful! A tip, in version 2.1.2 I'm using you have the set the array in the choice via an expression – Karl Jul 29 '22 at 08:07
  • I have been stuck for hours trying to Push a value into an array with the "Edit an array property" action. You showed me that I must leave the "Result property" box empty. Thanks! – cherry Oct 24 '22 at 10:15