Dynamic Dialog Generator
Using this function, you can use a list of items to be displayed dynamically on action blocks like Buttons, Carousel etc.
With the help of dialogGenerator
function, we can generate static dialog or dynamic dialog
(Using Service Call Dialog API response variable) in the form of Buttons, Carousal, List, Options and Reply Buttons.
Code-block function name: dialogGenerator
Property of requested arguments
type
this property refers to the type of dialog you need to generate like a button, carousel, etc.
data_variable
If you want to generate dialogs from JSON data(LikeService Call Dialog API response) this is a mapping of the variable that internally generates dialogs from that variable values(If any).
properties
This refers to particular dialog properties that every dialog uniquely contains.
goal
This property is used for goal tracking in the system. This is an optional property.
title
It refers to the title of the dialog. This is a required property.
button_properties
This property is used to configure the buttons generated by each dialog.
variable
This property is used to store selected response in a variable and it also defines the type of variable(Like contact or non_contact)(Note: This will only work if the variable is already defined in bot-flow)
Buttons
Buttons (with Branch)
Note - you need to insert inline JSON in the code-block argument.
Buttons (with URL)
Example arguments
Here to create dynamic URL buttons we need to set the type of button as âweb_urlâ
Also, there will be two more properties for the web_url button named âweb_urlâ and âbrowser_windowâ
The âweb_urlâ property will set the redirection URL on the button on which the user will click and it will redirect to that URL
âbrowser_windowâ is used to set the new redirected URL will open in the âsameâ window or in the ânewâ window. The value of this property will be from âsameâ or ânewâ
Example argument
URL buttons generated from API example
To generate dialogs dynamically we need to give a path to a particular level and also need to provide variables to generate dynamic dialogs
I have used service call dialog to get data variable which is used to generate dynamic buttons
Carousel
Static Carousel
This is a simple carousel dialog generated by static data
There will be two things that can be dynamically generated, those are cards and buttons in cards
Static Carousel example
The image carousel will be the same as a simple carousel but the difference will be of image URL
If you specify the image URL then it will generate a carousel with the image otherwise not
Dynamic Carousels
Dynamic carousels example
To generate dynamic cards from variables you need to provide the path as we have done in buttons in form of a look-up path for JSON
You can also provide a path to description and image to generate dynamic Cards and buttons as we do it for the title of cards and buttons in the carousel
List (for WhatsApp)
We also can generate a list dialog using this code block for WhatsApp only
We need to give the type as a list and provide other properties of the list
Here section_title refers to the section in the list, it is handled on the WhatsApp side to categorise buttons in one section
Buttons having the same section name will fall under one section
Dynamically Generated list Example
To generate dynamic buttons using variables we need to specify the lookup path for the JSON to the title and description
Options (for WhatsApp)
Static Options example
The options dialog is similar to the button dialog on the web, but it is available to generate buttons for WhatsApp only
Here button type is also the same as buttons for web channels just difference is that it can not generate web buttons as compared to web channels as WhatsApp does not provide support for web buttons
Dynamically generated Option example
To generate options dialog from variable we need to give a lookup path for JSON to the title property
Reply Buttons (for WhatsApp)
Static Reply Buttons example
Reply buttons are only available on the WhatsApp channels
It provides the same functionality as the reply button in WhatsApp, you can provide the functionality to attach different headers available on the WhatsApp side
We can also insert a footer and error message in the reply button dialog
Dynamically Generated Reply Buttons Example
To generate reply button from variable response one need to provide look up path for JSON to the title property. Other properties are static so we can not set path to other property
Last updated