Dynamic Dialog Generator
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)
Here to generate a simple button so we need to set the “type“ property to “button“
We have given other necessary properties to code-block arguments. And as we need to generate a static button we specified the “type” property in “button_properties“ as “branch” and gave the name of the button as the title in “button_properties“
We have set the variable name as “variable_name“ and the type of variable as “non_contact“
We can print the value of the variable “variable_name“ in the next dialog using #variable_name#
From the above-requested arguments, the code--block function will generate two buttons.
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
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
Here I have generated web buttons using dynamic data from API responses from the service call dialog
The value of the path of the variable which is generating dynamic buttons needs to be set according to the lookup path that is globally defined for JSON
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
Here I have generated web buttons using dynamic data from API responses from the service call dialog
The value of the path of the variable which is generating dynamic buttons needs to be set according to the lookup path that is globally defined for JSON
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
Card properties will generate cards for the carousel
Button properties situated inside card properties will generate buttons for particular cards
“title“ property at a particular object level will generate the title of that particular thing(ie. title inside card properties will be set title for the card and same for button properties)
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