Search code examples
botframework

How to passthrough dynamic variable value in bot framework composer when using array object


So my problem/challenge is that I am getting with http request some data which I would like to use to build dynamically multi button action.

So from my http request I might get 1 to many values which I would then use to build the out put actions to the bot in for each item loop.

Everything works if I use static content when adding new object to array e.g.

{ "type": "Action.Submit",
  "title": "my title",
  "data": "my data"
}

So this prints out button which says "my title"

But then I try to user property there to pass my data it only prints out the property name and not the value in it. So e.g.

{ "type": "Action.Submit",
  "title": "${turn.myTitle}",
  "data": "${turn.myData}"
}

And this prints out now just the property/variable name ${turn.MyTitle}

So is there any way of passing through the actual data here? I can see that if my type would be string the data is otherwise ok, but it is not anymore working as and object (because of extra double quotes in the start and end)


Solution

  • So answering to my own question as it seems to help when you keep your eyes off the topic for couple days :)

    So to pass through objects and then to create array:

    1. Use set properties to create your object values e.g. turn.action.<name/value> set properties to object
    2. After this use edit an array property where you just push your object as expression "turn.actions" push to array

    Once you have this the array should show correct values like:

    [ {"type":"Action.Submit"}, {"title":"<your title value>"}, {"data":"<your data value>"} ]
    

    And then then just loop this in foreach to build the multiple action buttons.

    ref: