Slot filling
Last updated
Last updated
Tous droits réservés @ 2023 dydu.
The goal of Slot Filling is to recover all the parameters matching an intention.
In order to answer correctly to the user, Slot knowledge type is created to capture and save the required parameters.
With this feature, the bot can detect if the user has sent all the information it needs. Otherwise, it automatically asks questions to get them.
This case study is based on a pizza order made through the bot. To order a pizza, two parameters are needed:
the number of slices and
the type of pizza.
These parameters correspond to the slots that we will create and use throughout this case study.
Our example is divided into three parts:
in the first part: we will create the first slot: the number of shares;
in the second part: we will configure the filling slot (i.e. create a knowledge that will use this slot);
Finally, we will create the second slot (the type of pizza) and add it to the existing filling slot.
Part 1: Creating the first slot: the number of slices
In our case, the number of slices is a positive number. The bot therefore expects the end user to enter an "integer".
We will therefore create a "Slot" type of knowledge that will allow us to understand the user's formulation, whatever the integer he enters. In order to be able to re-use the integer filled in by the end user, we will record it in a variable named "part".
In the response of this knowledge of type "Slot" we will display the input of the user thanks to the syntax ${capture.part}
Part 2: Configuring slot filling (using the slot created in a knowledge)
In this part, we will create a simple knowledge allowing us to understand the end-user's intention "I want to order a pizza". Within this knowledge, we will use the previously created slot (the number of slices) thus configuring our filling slot!
When using a slot in a knowledge, several options are available:
General options (these options will be applied to the whole slot filling)
Introductory sentence: the introductory sentence is the first sentence displayed to the end user when he/she enters the slot filling process. We use this sentence to inform the user that there is missing information in order to process their request. Example: "I need additional information to process your request".
Max. garbage count: This option allows you to determine after how many misunderstood sentences the slot filling process will be abandoned.
Confirm before leaving the slot: this option allows the bot to ask for the end user's confirmation to abandon the slot filling process.
End sentence: the end sentence is the sentence displayed to the end user when he/she abandons the slot filling process.
We use this sentence to inform the user that they are leaving the process. Example: "Are you sure you want to leave your current application? ".
Slot options (these options will only be applied for this slot and in this slot filling)
Settings tab:
Slot: this is where we select the slot to use;
Variable name: this is where we define a name for the variable that will record the response of the Slot knowledge (Slot knowledge that we created in the first part)
Required: this box (checked by default) implies that the information must be captured to continue the process. You can uncheck this box to indicate that the slot is optional (if it is not given by the end user, the bot will still be able to continue the process)
Reset: this box (checked by default) allows to reset the captured value. This allows you to modify the value of the slot. Here are the different possible behaviours:
Case 1: The user says "I want to order a pizza for 10" and then says "I want to order a pizza for 3".
If the box is not checked, the bot understands the value 10 and keeps it. If the box is checked, the bot understands the value 3 and overwrites the value 10.
Case 2: The user says "I want to order a pizza for 10" and then says "I want to order a pizza".
Even if the box is checked, the value is not reset: the first value included is still valid, i.e. the value 10.
Instructions tab:
Question that ask the value of the capture: this is where we write the sentence(s) we want to display to the end user to ask for the missing information.
Part 3: Create a second slot (the type of pizza) and add it to the existing slot filling
In this last part, we will create the last slot needed to proceed with the pizza order: the pizza type.
As several pizzas exist, we choose to create a group of formulations listing all the available pizzas.
We will then create a "Slot" type of knowledge that will allow us to understand the user's formulation whatever the pizza he/she enters among the available pizzas.
As with the creation of our first slot, in order to be able to re-use the type of pizza entered by the end user, we will record it in a variable named "pizza". In the response to this knowledge of type "Slot" we will display the user's input using the syntax ${capture.pizza}
Finally, we will add this slot to the simple knowledge "I want to order a pizza" (knowledge that we created in part 2)
In this case, the user declares an intention for which the bot needs two mandatory parameters to satisfy his request. To do so, the bot will successively recover this information from the user and thus to continue the process.
In this second case, the user sends to the bot one of the two parameters required to continue the process. Thus, the city parameter is filled in and the bot then only asks for the second parameter, which has not been given (the date). Once this parameter is retrieved, the bot is able to continue the process.
In the latter case, the user transmits to the bot all the required parameters. The bot then retrieves all the information and can directly continue the process of the user request.
As a first step, you must create and configure your slots that you can use later in your knowledge. Your slots correspond to the parameters to retrieve to answer the user's question. As part of our train ticket purchase example, the slots are City and Date).
Please follow these steps:
Go to the Knowledge page.
Click the New knowledge button at the top left of your page.
Click Slot.
Specify the type of content you want to retrieve in the user sentence to understand. In our case, we add the matching group allowing to recover a precise date (existing group by default).
Click Create.
You can then configure your answer just like answering a answer to a question. In our example, we decide to recover the day and the month.
The Date - Precise Date group can capture multiple information such as the day of the week, month, month, and year. Of this information, you can return in your answer all or only part of this information. In our example, we want to display only the day of the month and the month. Thus, we exploit the following captures: ${capture.date_dayofmonth} and ${capture.date_month}.
Repeat the process to create as many slots as you want. As part of our example, we've created a second slot that will retrieve the city whose variable name is city (thanks to a matching group consisting of names of city, created in advance):
Your slots are now created and configured. Note that you can add as many slots as you want.
You will now be able to exploit your previously created slots within your knowledge. To do so, please follow these steps:
Create a Answer to a Question to create the knowledge that will use the previously created slots. To do so, click Create knowledge then click Answer to a question.
Enter the user sentence and click Create.
Edit the user window (blue bubble) and click on the Slot filling tab.
Fill in the fields.
Introduction sentence: enter an introductory sentence to inform the user that information is missing to process the request. Example: "I need more information to treat your request".
Leaving sentence: enter an end sentence to inform the user that the slot filling request is abandoned.
Max. garbage count: this option allows you to determine after how many misunderstood sentences slot filling is dropped.
Leaving confirmation sentence: enabling this option allows you to request confirmation from the user to abandon slot filling.
Click Save.
Now you can use previously created slots and add them as a parameter for your knowledge.
Click Add (at the bottom of the page) to add a new slot parameter.
Description of fields:
Slot: this item allows you to select a slot;
Variable: this is the name of the variable that will store the result of the knowledge slot.
Prompts: this element allows you to add the sentences (and its alternatives) to asked the user again for missing information.
Options:
Required: checking this box implies that the information must be captured in order to continue the process. Unchecking this box indicates that the parameter is optional.
Reset: checking this box allows you to change the variable captured by the slot. Here are the different possible behaviors:
Case 1: the user says "I want to buy a train ticket for Paris" and then say "I want to buy a train ticket for Bordeaux".
If the box is not checked, the bot captures the value Paris. If the box is checked, the bot captures the value Bordeaux.
Case 2: the user says "I want to buy a train ticket for Paris" and then say "I want to buy a train ticket."
Even if the box is checked, the value is not reset and the first value captured is still valid, which is Paris.
Note: To edit Options you need to click on the ... on the right of the line, it will open a new window.
Click Update independently for each slot parameter to save your changes.
Note: you must click on the cross at the top right to leave the edition mode.
In our example:
In the answer window, enter the triggered answer when all defined parameters have been completed. We recommended to write a summary sentence of the situation. Then click Update.
Tip: you can click on the icon at the right of a variable (in the drop-down menu Configured Slot Filling) to copy the code to be inserted into your answer to display the variable.
Warning: if a slot is deleted after creating a knowledge exploiting this slot, the knowledge can not be looped if the parameter is mandatory. An error upon interaction will be triggered.
Next step: in order to enrich the content of your answers, you can learn more about the answers elements which will allow you to discover all the possibilities available to you.