Webview
Last updated
Last updated
To enrich user interaction we use Webview, which is responsible for picking up or displaying information more efficiently during the conversation flow. The idea here is for the user to have the experience of being in a conversation with the bot and at the same time using features of a web or mobile application.
The Webview can be triggered during the conversation flow only through the button of a card-type message.
We are currently providing 3 types of Webviews: Form Fields, Advanced, and External URLs.
Here we have the option to present a form with fields of the User object to be filled. All behavior is controlled by the CosmoBots platform.
The Webview Height defines which percentage of the screen will be occupied by Webview. It is interesting to use a height that does not cover 100% of the screen, so the user will realize that he is still in chatbot.
Here is an example of how this Webview looks to the user:
Upon completion of Webview all form data will be saved to the CosmoBots database.
This type of Webview has more features. And it relies on different layouts to present information to the user.
Layouts need to be populated and placed in the variable called webview. The following are the attributes available for all layouts:
Atributo
Tipo
Descrição
id
String
Identifier of the layout. Any String can be defined. Required.
header
String
Layout header. Required.
buttons
Array
Set of navigation buttons that appear at the end of the layout. Required.
The fields are:
label: button label
next_id: if it is within a Layout Set, define here the id of the next layout
go_back: if it is within a Layout Set, it defines if the button action is to go back to the previous layout
required: indicates whether you need to select an item before proceeding
save_record: indicates whether to save the record of the current layout data.
options
Object (JSON)
Additional layout options:
min_select: minimum of items to be selected (Number)
max_select: number of items to be selected (Number)
min_item_quantity: minimum quantity of each item (Number)
max_item_quantity: maximum quantity of each item (Number)
show_limit_select: shows message about the limit of items to be selected (Boolean)
show_limit_quantity: shows message about the quantity limit of each item to be selected (Boolean)
And now we go to the details of each layout, containing examples of use:
Here are the additional attributes for this type of layout:
Atributo
Tipo
Descrição
type
String
Layout type: select. Required.
data
Array
Data that will be used to assemble the list. Required.
selected
Array
Items already selected.
response
String
Name of the variable that will have the items selected after Webview is completed. Required.
fields
Object (JSON)
Name of the fields used to display information about each item. Required. The options are: title, subtitle, price, currency.
Here's an example of how to fill out this layout:
Here are the additional attributes for this type of layout:
Atributo
Tipo
Descrição
type
String
Layout type: select_product_quantity. Required.
data
Array
Data that will be used to assemble the list. Required.
selected
Array
Items already selected.
response
String
Name of the variable that will have the items with the quantities selected after Webview is completed. Required.
fields
Object (JSON)
Name of the fields used to display information about each item. Required. The options are: title, subtitle, quantity, price, currency.
Here's an example of how to fill out this layout:
Here are the additional attributes for this type of layout:
Atributo
Tipo
Descrição
type
String
Layout type: select_address. Required.
data
Array
Data that will be used to assemble the list. Required.
selected
Array
Address record already selected.
response
String
Name of the variable that will have the address record selected after Webview is completed. Required.
fields
Object (JSON)
Name of the fields used to display information about each address record. Required. The options are: street, number, complement, neighborhood, city, state, zipcode.
Here's an example of how to fill out this layout:
Here are the additional attributes for this type of layout:
Atributo
Tipo
Descrição
type
String
Layout type: list_orders. Required.
data
Array
Data that will be used to assemble the list. Required.
fields
Object (JSON)
Name of the fields used to display information about each item in the list. Required. The options are: order_number, status, confirmation_date, payment_method, subtotal, freight, total, currency.
Here's an example of how to fill out this layout:
Here are the additional attributes for this type of layout:
Atributo
Tipo
Descrição
type
String
Layout type: show_total. Required.
response
String
Name of the variable that will have the information about the total values after Webview completes. Required.
fields
Object (JSON)
Name of the fields of the selected items that will be used to calculate the total values. Required. The options are: freight, price, quantity, currency.
Here's an example of how to fill out this layout:
Here are the additional attributes for this type of layout:
Atributo
Tipo
Descrição
type
String
Layout type: new_record. Required.
response
String
Name of the variable that will have the new record information after Webview is completed. Required.
fields
Object (JSON)
Name the fields of the new record to be created. Required. The options depend on which fields you want the user to fill. As an example of creating a new address, the fields would be: street, number, complement, neighborhood, city, state, zipcode.
Here's an example of how to fill out this layout:
And finally, we have the option of defining a Layout Set. It would be like a step by step that the user needs to follow to complete the Webview. To do this simply add each layout inside the webview variable to the order that you want them to appear to the user.
Here is an example where the scenario here would be to finalize a purchase:
There is also the option of having Webview originated in some external URL to CosmoBots. So the control would not be on the CosmoBots platform but could use a step following it to, for example, call an API to query or update information from the context of the conversation.