Help Center

How to generate a selection list with dynamic options in Aivo Studio?


This flow allows you to create a form complement with a dynamic selection list for all channels

About Function Node "Set Initial Params"

In this node the necessary objects will be created:

* msg.count => Counter required for enumerating the dynamic list

* msg.dynamicCallbackLabel => Object that will store the "callback_label" for asynchronous channels

* msg.dynamicSelectOptions => Object that will store the options for synchronous channels

About Function Node "Data Mockup - Users List"

Here is where the object is set, which gives us a fake endpoint response.

About Loop Node "Users Loop"

This node iterates the object that contains the data mockup.

About Function Node "Build The List"

* The variable "lineBreak" contains the line break for the asynchronous channels options.

* The "getNumberEmoji" function receives a numeric value and returns a numeric emoji.

* The counter is incremented.

* The values are stored dynamically in the objects "msg.dynamicCallbackLabel" and "msg.dynamicSelectOptions".

About Form Node

This node is used to generate the basic structure of a form within the "complements" object.

About Function Node "Set Form Options"

This node replaces the static properties "callback_label" and "options" with the dynamic 

objects previously created in the node "Build The List".

How to test this flow?

You need to execute the Inject Node and then you can see the result in the "debug" console.

How to use this flow?

* The setting of the function node "Set Initial Params"  must not be changed.

* The function node "Data mockup - User list" must be replaced by the data obtained from a Request (using http request node).

* The data obtained by the http request node will be in the "payload" object.

* Important: This data must be transferred to another object (in the example:, since this “payload” object will be replaced in each iteration of the Loop node.

* Within the "Build The List" node, the option will be stored dynamically in each iteration of the loop. (in the example:

* This will create the objects that will contain the selection lists (in the example: msg.dynamicCallbackLabel and msg.dynamicSelectOptions).

* Finally these objects will be usted to replace the parameters of the form, as follows:

    - msg.payload.complements[0].param[0].callback_label = msg.dynamicCallbackLabel;

    - msg.payload.complements[0].param[0].options = msg.dynamicSelectOptions;


Download the flow by clicking on this link.

This website stores cookies on your computer. These cookies are used to collect information about how you interact with our website and allow us to remember you. We use this information in order to improve and customize your browsing experience and for analytics and metrics about our visitors both on this website and other media. To find out more about the cookies we use, see our Privacy Policy.

If you decline, your information won’t be tracked when you visit this website. A single cookie will be used in your browser to remember your preference not to be tracked.