Another way to write shorter stories, or to handle multiple intents the same way, is to use an or statement.
For example, if you ask the user to confirm something, and you want to treat the affirm and thankyou intents in the same way. The story below will be converted into two stories at the training time:
# stories.yml
# ... previous content ...
- story: confirm by affirm or thankyou
steps:
- intent: confirm
- action: utter_ask_confirm
- or:
- intent: affirm
- intent: thankyou
- action: utter_confirmed
For this example to work, apart from the code we have from the previous chapters, I have created two new intents:
# data/nlu.yml
# ... previous content ...
- intent: confirm
examples: |
- can I confirm
- I want to confirm
- I would like to confirm that
- intent: thankyou
examples: |
- thank you
- thanks
- thanks a lot
- thank you so much!
and added them to domain.yml
:
# domain.yml
# ... previous content ...
intents:
# ... previous intents ...
- confirm
- thankyou
We need the chatbot's responses as well:
# domain.yml
# ... previous content ...
utter_ask_confirm:
- text: Do you really want to confirm that?
utter_confirmed:
- text: Confirmed.
Let's see this in action:
You can learn more about OR statements in the documentation.
In the next chapter, we will look at slots in detail.
Repository for this tutorial:
You can checkout the state of the repository at the end of this tutorial by running:
git clone --branch 14-or-statements git@github.com:petr7555/rasa-dev-tutorial.git
Top comments (0)