Petr Janik
Posted on May 20, 2021
You can use checkpoints to modularize and simplify your stories. Checkpoints can be useful, but do not overuse them. Using lots of checkpoints can quickly make your example stories hard to understand, and will slow down training.
Here is an example that contains checkpoints:
# stories.yml
# ... previous content ...
- story: beginning of flow
steps:
- intent: ask_how_i_feel
- action: utter_ask_user_question
- checkpoint: check_asked_question
- story: handle user affirm
steps:
- checkpoint: check_asked_question
- intent: mood_great
- action: utter_great
- checkpoint: check_flow_finished
- story: handle user deny
steps:
- checkpoint: check_asked_question
- intent: mood_bad
- action: utter_bad
- checkpoint: check_flow_finished
- story: finish flow
steps:
- checkpoint: check_flow_finished
- intent: goodbye
- action: utter_goodbye
Checkpoints can have any name.
For this example to work, apart from the code we have from the previous chapters, I have created the following intents:
# data/nlu.yml
# ... previous content ...
- intent: mood_bad
examples: |
- my day was horrible
- I am sad
- I don't feel very well
- I am disappointed
- super sad
- I'm so sad
- sad
- very sad
- unhappy
- not good
- not very good
- extremly sad
- so saad
- so sad
- intent: goodbye
examples: |
- cu
- good by
- cee you later
- good night
- bye
- goodbye
- have a nice day
- see you around
- bye bye
- see you later
- intent: ask_how_i_feel
examples: |
- Ask me how I feel
- Do you want to know how I feel?
- Ask me about my feelings
and added them to domain.yml
:
# domain.yml
# ... previous content ...
intents:
# ... previous intents ...
- mood_bad
- goodbye
- ask_how_i_feel
We need the chatbot's responses as well:
# domain.yml
# ... previous content ...
utter_ask_user_question:
- text: How do you feel?
utter_great:
- text: Glad to hear that!
utter_bad:
- text: I'm sorry to hear that.
utter_goodbye:
- text: Bye
You can learn more about checkpoints in the documentation.
In the next chapter, we will look at OR statements.
Repository for this tutorial:
You can checkout the state of the repository at the end of this tutorial by running:
git clone --branch 13-checkpoints git@github.com:petr7555/rasa-dev-tutorial.git
Posted on May 20, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.