Rasa Conditional Response Variation not working with buttons

I’m using Rasa conditional response variation for a scenario in my code which uses buttons for further process

This is the response.yml

  utter_ask_open_user_personal_info:
  - condition:
    - type: slot
      name: user_name
      value: null
    - buttons:
      - payload: /affirm
        title: Yes
      - payload: /deny
        title: No
      text: would you like to provide name and other details".     
  - buttons:
    - payload: /affirm
      title: Yes
    - payload: /deny
      title: No
    text: Would you like to provide additional details such as Age and Gender? You can skip questions or close this form at any time by typing "skip" and "skip all".     
 

If I use conditional response just for text, It works! but when I’m adding buttons during training it is throwing the following error

YamlValidationException: Failed to validate 'rasa_adam\domain.yml'. Please make sure the file is correct and all mandatory parameters are specified. Here are the errors found during validation:
  in rasa_adam\domain.yml:531:
      Key 'buttons' was not defined. Path: '/responses/utter_ask_open_user_personal_info/0/condition/1'
  in \rasa_adam\domain.yml:531:
      Key 'text' was not defined. Path: '/responses/utter_ask_open_user_personal_info/0/condition/1'

Is my formatting wrong or Rasa conditional response supports only texts as of now?

I think you missing other condition

Look this example:

responses:
  utter_greet:
    - condition:
        - type: slot
          name: is_new_user
          value: true
      text: "Thank you for signing up! What do you need help with?"
    - condition:
        - type: slot
          name: is_new_user
          value: false
      text: "Welcome back! What do you need help with?"

But, what do you think, use two different response and put the condition in store.yml?

  • utter_ask_open_user_personal_info
  • utter_ask_open_user_personal_info_additional_details

Hi @itsjhonny

Even if we have one condition in our response it will work as IF-ELSE
That is if the condition fails the other text is displayed which is outside the conditional scope. I have incorporated this in my code here

  utter_greet:
  - condition:
    - type: slot
      name: user_name
      value: null
    text: Hey! I'm Adam, How are you today?
  - text : Hey {user_name}👋 I'm Adam, How are you today?

And it works!

The problem that I’m facing is the addition of button inside of a conditional scope

You are right about conditions! Thanks :blush:

I think your problem is just a little yml error (- buttons:) . Can you check your domain.yml here?

And… can you test it? Its working for me :blush:

responses:
  utter_ask_open_user_personal_info:
  - condition:
      - type: slot
        name: user_name
        value: null
    buttons:
      - payload: /affirm
        title: Yes
      - payload: /deny
        title: No
    text: would you like to provide name and other details. 

  - buttons:
    - payload: /affirm
      title: Yes
    - payload: /deny
      title: No
    text: Would you like to provide additional details such as Age and Gender? You can skip questions or close this form at any time by typing "skip" and "skip all".

Hi @itsjhonny, It worked! Thank you so much :blush: Adding that hyphen was causing all that trouble :sweat_smile:

1 Like