Forms
Last Updated: 25.10.2019
Last updated
Last Updated: 25.10.2019
Last updated
Hala can respond to the user with a form. You can use the forms in case you need to collect from the user more than three values. In case you ask the user ten questions, they can become tedious, and the process for them will be more complicated. With forms, you can collect all the information in one step and simplify the process.
Following image represent the example of the form in the chat:
There are the following types of text fields that you can use to create the form.
Type | Description |
Text | A text field is a graphical control element intended to enable the user to input text information into the form |
Select box | The select box element is used to create a drop-down list and give the user the opportunity to select one of the value |
Radio button | A radio button is an element that allows the user to choose only one of a predefined set of mutually exclusive options |
Checkbox | Checkboxes are used to let a user select one or more options for a limited number of choices |
Long text | With this field, users can enter the long text, for example, a description of the problem for the creation of a new incident |
Date | The date field is designed for the date selection |
Text with suggestions | The element is providing to the users' different predefined text to speed up the form entering. Users can click on one of the suggestions and Hala will take this value as an input |
You can find more information about the adding the forms and fields in sections below.
The following diagram describes the process flow when we are sending the form to the user, and then we process the response from the user.
The end-user sends the request to create a new user in the external application.
Hala matches the user input with the condition of the skill "Create a new user." Based on the output configuration in the skill node, Hala responds to the user with the form.
The end-user is filling out the form and save results.
Hala is storing the results (values that the user entered in the form) in context variable context.formResult
. Later you can access the information that users provided in the Form by using context.formResult.key_field_name
In case the user wants to cancel the Form, the result will be stored in context variable context.formCanceled
. We need to process each action of the user to provide the appropriate response. For example, if the user will cancel the form, then we will trigger the child node with the condition context.formCanceled. Also, we can configure our response for this child node like this: "The form is canceled. How can I help you else?"
When users will fill out the form, then we would need to get the values that the users entered in the form. We need these values, because, for example, we can send the results to the backend software and create some object on the backend side.
All the results of the forms are storing into the two context variables:
Context Variable | Description |
| In case the user presses "Save" after filling the form, all values will be stored in this context variable. |
| In case user will press "Cancel" after the filling the form, all values will be stored in this context variable. |
For example, you have sent to the user next form:
Users will see two fields: "Username" and "Country."
Let's assume that in the field "Username" they have entered the value Andrew
, and in the field "Country" they have entered the value Estonia
.
So if you want to access those values in the following nodes, you can use next syntax:
You can use the expert mode to add the forms. The expert mode becomes available by pressing the button next to the word "Output."
Here is the example of JSON format for the forms:
The Form has header information and the items information.
Header information:
Parameter | Description |
| For the form output always value |
| The name of the form that will be displayed in the chat |
| An array of all the input fields included in the Form. Each object contains the information required for building an input field. |
Item information:
Parameter | Description |
| The name of the input field. |
| A unique key to distinguish each input field in the form and for storing the value that the user will enter. |
| The HTML type of the input field. It can be: "text", "select", "radio", "checkbox", "longText", "date" |
| A Boolean value indicating if the input field is mandatory or optional |
| The value of the input, it is empty by default when creating a new form, and populated with the info, when using the form to edit an existing form |
| You can use it only with field type "text." It contains title - a String value describing the values, and suggestions - an Array with suggested values that the user can use to populate the input field. |
| String value describing the form field |
| An object with validation rules. More info on https://github.com/yiminghe/async-validator |
| An array of string values to populate the options of the "radio" and "select" output types |
A text field is a graphical control element intended to enable the user to input text information into the form.
How it looks like in the chat
The select box element is used to create a drop-down list and give the user the opportunity to select one of the value.
How it looks like in the chat
A radio button is an element that allows the user to choose only one of a predefined set of mutually exclusive options.
How it looks like in the chat
Checkboxes are used to let a user select one or more options for a limited number of choices.
How it looks like in the chat
With this field, users can enter the long text, for example, a description of the problem for the creation of a new incident.
How it looks like in the chat
The date field is designed for the date selection.
How it looks like in the chat
The element is providing to the users' different predefined text to speed up the form entering. Users can click on one of the suggestions and Hala will take this value as an input.
How it looks like in the chat