Available in: Botfront Enterprise
In-depth tutorial available
An in-depth step-by-step tutorial is available here. We recommend starting there and use this documentation article as a reference.
Stories are great to model conversation flows but they are not always sufficient to implement slot filling. Slot filling is an iterative process during which questions are asked and responses are validated.
Slot filling can be used to prepare an API call (e.g asking travel requirements before checking flights availability), or more generally to collect information such as user details in a contact form.
There are two mains steps in implementing forms:
- Creating and configuring the form
- Integrating the form in your stories.
You can create a form from clicking the + button at the top of the sidebar.
Enter a name and type enter. The name should always end with
_form. For example,
When you create a form, you can add a description and list the slots you want to get filled.
When saving, the slots become visible in the sidebar under the newly created form. You can re-order slots if you want to change the order of the questions.
Botfront will create unfeaturized slots for you if the slots you list don't exist.
Remember that the output of a form is a list of slots filled with valid values. We need to:
- Specify the questions we want to ask for each slot we want to collect.
- Specify validation rules.
- Speficy how we want to extract the values (from an entity, an intent, the whole user message).
Under the Question tab you can specify the questions your assistant will ask to collect a value for each slot.
Note that the question is technically a Botfront response with all the responses features: you can add variations and highlight elements on the screen.
You can use any response type:
You can validate the user response and display a message depending on the result:
In the following example, we expect the value of the
first_name slot to have more than 2 characters.
If the value is invalid, the error message will be uttered and the question will be repeated.
You can also optionnally display a confirmation message when the slot is set and valid. This message will be uttered each time a new value is set for the slot: when the question is answered for the first time, or when the user changes it later in the flow.
Note that you can use the value of the slot in these messages.
It's a good idea to add variations to make the assistant less robotic while repeating questions.
A variety of validation options are offered, and if they are not sufficient you can also match a regular expression.
There are several ways to extract information from an utterance.
You may want to take the value from an entity: if the user says my email is email@example.com where firstname.lastname@example.org is extracted as an
When asking the user to approve or reject the policy, it feels more natural to ask if they approve and expect a yes or no answer. Where yes carries the
affirm intent and no the
You can map the intent to the expected approved or rejected values as follows.
For more generic questions, such as free form messages, you can just fill the slot from the user message.
You may add further constraints on the intent.
For example, when collecting the email from an entity, you may want to ensure that the intent corresponds to declaring an email address (e.g my email is email@example.com) and not something else such as I wrote an email to firstname.lastname@example.org and no one replied:
The inclusive condition below will make sure that the slot is filled from the
first_name entity if and only if the intent
inform is recognized. If any other intent is found the form will be interrupted and you will have to handle that in your story.
The exclusive condition below will always fill the
message slot from the whole content of the user message, unless one of the listed intent is found. It will then interrupt the form and you can take the conversation from there in your story,
Combining extraction methods will allow your assistant to extract the slot with more robustness. When asking a first name, a user might answer John, or I’m John, or my name is John.
inform intent is found with a
first_name entity the slot will be filled from the entity. Otherwise, the whole message will be taken.
In the From the user message condition we have excluded the inform intent in order to make both conditions mutually exclusive.
Now that we have a form we may start using it in our stories.
The simplest integration covers the ideal situation where the user is collaborative and answers all questions. You only need to start the form in your story. Once it is active it is going ti iterate through all slots, ask questions, validate answers, etc.
You can pick up after completion to continue the conversation once all the slots have been filled succesfully.
The recommended approach is to use branches and links to handle digressions. Please check our in-depth tutorial for an extensive example.
Contextual questions are questions with responses depending on information being collected. For example Explain or Why do you need this. Contextual questions must be explicitely enabled in the form configuration:
At training time, a categorical
requested_slot will be added to the domain with all slots contained in all forms as categories.
Once contextual questions are enabled/disabled for one form, it is enabled/disabled for all forms
Please check our in-depth tutorial for an extensive example.