DEV Community

Cover image for RASA - OR statements
Petr Janik
Petr Janik

Posted on • Edited on

2 2

RASA - OR statements

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


Enter fullscreen mode Exit fullscreen mode

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!


Enter fullscreen mode Exit fullscreen mode

and added them to domain.yml:



# domain.yml
# ... previous content ...
intents:
  # ... previous intents ...
  - confirm
  - thankyou


Enter fullscreen mode Exit fullscreen mode

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.


Enter fullscreen mode Exit fullscreen mode

Let's see this in action:

Conversation with OR first

Conversation with OR second

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


Enter fullscreen mode Exit fullscreen mode

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

Top comments (0)

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up