After the upgrade to 3.0 the domain_slots.remove("variable") function does not work anymore

I’m excited about the new Rasa 3.0 release, thanks rasa developers! :slight_smile:

Unfortunately, I’m running into an issue which was not happening before the upgrade with the dynamic form behavior. Specifically, the bot asks the user “Can I ask your age?” If the user says no, then the slot age will be removed from the form slots through domain_slots.remove(“age”). When I run my custom action however I get the error: ValueError: list.remove(x): x not in list What am I missing?

Thank you!

class ValidateUserProfileForm(FormValidationAction):
    def name(self) -> Text:
        return "validate_user_profile_form"
    
    async def required_slots(
            self,
            domain_slots: List[Text],
            dispatcher: "CollectingDispatcher",
            tracker: "Tracker",
            domain: "DomainDict",
    ) -> Optional[List[Text]]:
        if not tracker.get_slot("can_ask_age"):
            domain_slots.remove("age")

        return domain_slots

Here is the slot definition and the form:

  can_ask_age:
    type: rasa.shared.core.slots.BooleanSlot
    initial_value: null
    influence_conversation: false
    mappings:
    - intent: affirm
      type: from_intent
      value: true
      conditions:
      - active_loop: user_profile_form
        requested_slot: can_ask_age
    - intent: deny
      type: from_intent
      value: false
      conditions:
      - active_loop: user_profile_form
        requested_slot: can_ask_age
  age:
    type: rasa.shared.core.slots.TextSlot
    initial_value: null
    influence_conversation: false
    mappings:
    - entity: age
      type: from_entity
      conditions:
      - active_loop: user_profile_form
    - type: from_entity
      entity: age

forms:
  user_profile_form:
    ignored_intents: []
    required_slots:
    - question_ready
    - age
    - can_ask_age
    - question_one
    - question_two
e2e_actions: []

What do you see if you do print(domain_slots) before remove()?

Not sure if that’ll solve it, but try:

if not tracker.get_slot("can_ask_age"):
    return [slot for slot in domain_slots if slot != 'age']

return domain_slots

Hi Chris, Thank you for your help! Unfortunately, it does not solve the problem. I’m also wondering, when the form gets activated, the questions are not displayed as before. The first question “question_ready” does not show up, neither the question “Can_ask_age” … Not sure what has been changed internally in forms through the new slots definition. Are there more specific information required? … Really appreciate your help! … If this remove() function does not work smoothly do you have an idea how I could solve those conditional questions differently? E.g. having different responses in the age utter e.g “How is your age?” vs. “Okay, it’s fine to not tell your age” depending on whether the user has indicated that they are okay when the bots asks for their age vs. not okay? I mean there are several ways for doing that within a conversation but in the case of forms it seems very difficult to me

Really weird that remove() doesn’t work. Did you do print(domain_slots) before remove() to see what it gives you?

The names of the utterances should be utter_ask_slotname or action_ask_slotname.

Unfortunately, it does not print the domain slots, it just shows the error message. But thank you for your advice with the syntax of the utters… I had a typo, now they are displayed :slight_smile:

Do you have an idea where I find a working example of this conditional behavior? When looking at formbot from RASA, there they have the example that the value of “outdoor_sitting” is set to true or false, depending on whether the user said yes to “do you want to sit outside” but this setting takes place silently. In my case, depending on “can I ask your age” the user is asked a further question or not. As I said this worked well in Rasa 2.8 but now I have no idea whether age needs to be included in the form or not, whether I should define it as a slot and then just add it to the form when Can ask age is true… And do I need a custom extract method in this case. I think Rasa 3.0 is a huge improvement, would just be great to be pointed to a working example with those conditional questions. Maybe you know one :slight_smile:

1 Like

It should print it on the terminal where you ran rasa run actions. Are you sure it doesn’t appear? :sweat_smile:

Ah, that’s great :smiley:

Other than the slot syntax in the domain, did you change anything?

As far as I can tell, you code is fine, for both Rasa and Python :confused:

Yes, this is the solution I wanted to give you, it should work.

I just noticed those last two lines… Can you try again without those? Or by only keeping those?

The 2nd mapping is the same as the 1st one, which makes the 1st one useless.

I don’t think it will work, but I’d at least try :sweat_smile: