Entities are automatically saved to slots that have the same name.
Let's create a new age entity:
# domain.yml
# ... previous content ...
entities:
# ... previous entities ...
- age
and a new age slot:
# domain.yml
# ... previous content ...
slots:
# ... previous slots ...
age:
type: text
influence_conversation: false
Let's create a new intent as well:
# data/nlu.yml
# ... previous content ...
- intent: inform_age
examples: |
- My age is [20 years](age)
- I am [15](age)
- I am [47 years](age)
- I am [8 years](age) old
and add it to domain.yml
:
# domain.yml
# ... previous content ...
intents:
# ... previous intents ...
- inform_age
We need the chatbot's response as well:
# domain.yml
# ... previous content ...
utter_age_back:
- text: Your age is {age}.
The story now looks like this:
# stories.yml
# ... previous content ...
- story: tell age
steps:
- intent: inform_age
- action: utter_age_back
Let's see this in action:
The age entity was automatically saved to the age slot, because the name is the same.
Also, you can see that slots can be overwritten. First, the value of the slot was 17 years and then 64.
If a form contains a slot that is filled before the form is activated, that slot is not asked anymore as part of the form loop.
To demonstrate this, let's create the following story:
# stories.yml
# ... previous content ...
- story: tell email
steps:
- intent: inform_email
- action: utter_email_back
Normally, the chatbot would ask "What is your email address?" to fill the email slot. But since the slot is filled beforehand, it asks only frequency and notifications.
You can learn more about slots in the documentation or in my previous article.
In the next chapter, we will look at rich responses, such as buttons and images.
Repository for this tutorial:
You can checkout the state of the repository at the end of this tutorial by running:
git clone --branch 15-slots-in-detail git@github.com:petr7555/rasa-dev-tutorial.git
Top comments (1)
simple and great explanation... thanks