Slot Filling
Slots are a significant concept in Digital Agent NLU. You can think of them as necessary parameters to complete the action associated with an intent.
Slot Tagging​
Digital Agent Native NLU will tag each word (token) of user input. Words separated by a hyphen are treated as one token. If the token is correctly identified as a slot, it will be attached to the NLU extraction event. Each identified slot will be accessible in the event.nlu.slots
object using its name as the key.
Defining Slots​
To define a slot for a particular intent:
- Click the NLU tab.
- Open the Intent Section.
- Select the intent you want to add slots to, then you'll be able to define your slots.
- Click the Create a Slot.
Let's use a book_flight
intent. To book a flight, we'll define two slots: departure
and destination
, both associated with the Airport Codes
custom list entity. Once that is done, we need to identify every airport slot
Example:
The user said: I would like to go to SFO from Mumbai.
event.nlu.slots
will look like:
slots : { airport_to: { name: 'airport_to', value: 'SFO', // shorthand for entity.data.value entity: [Object] //detailed extracted entity }, airport_from: { name: 'airport_from', value: 'BOM', // shorthand for entity.data.value entity: [Object] //detailed extracted entity } }
Slot Filling​
Slot filling is the process of gathering information required by an intent. This information is defined as slots as we mentioned in the above section. It handles input validation and the chatbot's reply when the input is invalid. Digital Agent has an in-built skill to handle the slot filling process.
Creating a Slot Skill​
We will use the slots which we defined earlier in this tutorial.
- In the Flow Editor view, click on Insert skill > Slot.
- Choose an intent to use for the slot filling.
- Choose a slot to fill.
- Choose the content that your chatbot will ask. It should be a question about the information you seek, such as "From where are you departing?" or "Where do you want to go?" etc.
- Choose the content for your chatbot reply when the input is invalid. It should guide the user towards a valid answer.
Validation Types​
There are two types of validations:
- Input validation: The first validation is based on entity extraction. If the provided information doesn't match the entity of the slot, the chatbot will notify the user. This will not apply when the slot has the type
@system.any
. In this case, the chatbot will ultimately provide the complete user phrase when it fails to match a slot confidently. - Custom Input Validation: you can use an action to add custom validation, such as regex or type validation (number, string). The action should set the variable
temp.valid
to eithertrue
orfalse
based on the validation result.
Max Retry Attempts​
How many times the chatbot should try to get the correct answer. On not found
outcome will be triggered when the maximum is reached.
Outcomes​
Three outcomes are possible:
On extracted
- The slot has been successfully extracted. It will be stored insession.slots.<slot_name>
.On not found
- The slot has not been extracted. This will also happen when the maximum number of retries is reached or when custom validation fails.On already extracted
- The slot has previously been extracted. One use-case for that would be to ask the user if the previous information is still relevant or if he would like to overwrite it.
Chaining Multiple Slots​
You can chain multiple skills to fill all the slots for a given intent. Chaining skills is handy when all the slots in a given intent are mandatory for a data set to be complete. In the flight booking example, we need the departure city
, destination city
, and time of departure
to check if a flight is available. Since these fields are mandatory, this is a good use case for skill chaining.
This flow will result in a conversation like the one below. Notice that in the first phrase, I want to book a flight to NYC
, the intent book-flight
is matched, and NYC has been extracted as the to
slot. Then, the chatbot tries to fill the remaining slots from
and when
.
Guidelines When Adding Slots​
- Mix the positions of the slots in the utterances.
Example:
- Avoid duplication when using slots.
Example - to avoid:
- Limit the number of slots used for a given Intent.
Suggestion: maximum of 3
- Try mixing utterances with the slots to be: filled, partially filled, or empty.
Example:
- Examples in utterances should match the defined entity.
Example: Entity list
: Google, Slack, Github, Email Intent
: Reset Trello password
(Slot value is not part of the list)
- When using slots, there have to be at least five utterances with an example of the slot; the more slots, the more utterances with examples.
Confluence Cloud Migration Alert: Please refer to known issues you may encounter in Confluence Cloud: https://eitdocs.atlassian.net/wiki/x/wDGwAQ