Conditional Response Variation with multiple values for entity

Hi there, This is my first post. I have been using rasa for a while and enjoyed the different functionalities. I have tested the CRV function and like it. However, I would like to know how to set a condition with multiple entity values for an entity of type categorical. For example, this blogpost Conditional Response Variations: Technical Blog | The Rasa Blog | Rasa shows a case with one value for entity for each condition. I want to do something like this:

slots:
time_of_day:
    type: categorical
    values:
        - morning
        - afternoon
        - evening
    influence_conversation: false`

responses:
  utter_welcome:
    # Pool I
    - text: "Good morning and welcome on Slack! This is your first time here so I'll help you get set-up."
      condition:
        - type: slot
          name: time_of_day
          value: morning; afternoon

Now I know I can duplicate the response as follows but want a shortcut because my domain is already very big:

responses:
  utter_welcome:
    # Pool I
    - text: "Good Day and welcome on Slack! This is your first time here so I'll help you get set-up."
      condition:
        - type: slot
          name: time_of_day
          value: morning
# Pool II
    - text: "Good Day and welcome on Slack! This is your first time here so I'll help you get set-up."
      condition:
        - type: slot
          name: time_of_day
          value: afternoon

IThanks

1 Like

Hello! :slight_smile:

I don’t think there is a way to do that, but it would be a great addition.

If you do the below, the two conditions will be ANDed, which can not happen. time_of_day will need to be morning AND afternoon.

responses:
  utter_welcome:
    - text: "Good Day and welcome on Slack! This is your first time here so I'll help you get set-up."
      condition:
        - type: slot
          name: time_of_day
          value: morning
        - type: slot
          name: time_of_day
          value: afternoon

If you want them to be ORed instead, so that time_of_day will need to be morning OR afternoon, you will have to do it like so:

responses:
  utter_welcome:
    - text: "Good Day and welcome on Slack! This is your first time here so I'll help you get set-up."
      condition:
        - type: slot
          name: time_of_day
          value: morning
    - text: "Good Day and welcome on Slack! This is your first time here so I'll help you get set-up."
        - type: slot
          name: time_of_day
          value: afternoon

To be honest, it’s just one more line of difference. But your suggestion would be way better indeed.


You could also use Custom Actions.

if tracker.get_slot('time_of_day').lowercase() in ['morning', 'afternoon']:
    dispatcher.utter_message('Good Day and welcome on Slack! This is your first time here so I'll help you get set-up.')

Thanks for your answer @ChrisRahme. the example is small but I use this for +400 line of domain based on CRV, having this feature added by rasa can save me a lot of time/trouble. For the custom actions, I’m not a real fan of them, things could get complicated very fast with the project scaling, so I’ll stick for the copy/past when there is not alternatives.

1 Like