Issues with dynamic form behavior -> added slots mappings

Hi, I´m working with a dynamic Form in Rasa 3.x. Depending on the user input I have to ask further questions, what is easily accomplished by dynamic form behavior in the ValidateFORMNAME Class → required_slots function. Until now I have been ADDING slots whenever the condition is right.

However, I´m facing an issue. In the required slots function, I have an if statement that tests the value and adds a slot to the form like this:

        if tracker.slots.get("slotname") == "condition":
            additional_slots.append("slotname2")

this works, but I´m having issues with my mappings. Let´s say I define slotname2 as follows:

  slotname2:
    type: bool
    mappings:
      - type: from_intent
        intent: affirm
        value: true
        conditions:
          - active_loop: simple_lead_form
            requested_slot: slotname2
      - type: from_intent
        intent: deny
        value: false
        conditions:
          - active_loop: simple_lead_form
            requested_slot: slotname2

basically, whenever I´m asking for that specific slot in the form, when the user answers with anything positive, the slot will be “true”, and if the user answers with something negative, the slot will be “false”. This has proven to work really well for the slots that have been already defined as requested slots in the form, as I´m working basically with “yes/no” questions. However, whenever I map slots like this that aren´t included in the required_slots of the form, I can´t train my model :face_with_raised_eyebrow: I get the following warnings:

UserWarning: Slot 'slotname2' has a mapping condition for form 'simple_lead_form', but it's not present in 'simple_lead_form' form's 'required_slots'. The slot needs to be added to this key.
Project validation completed with errors.

Is there a workaround for this? I could change the logic of my bot to add ALL of the slots and take them away from the form depending on the situation, but I´ve got around 400 slots. Is there another option for this? Maybe add all of the slots to the form and redefine the required slots in ActionSessionStart?

Thanks in advance! Any help is appreciated :slight_smile:

@matlafu Hi did you find any solution to this?

yeah, I ended up overwriting the form validation class so I can add all the slots to the form and only ask for them if a condition is met, kind of doing the opposite of what I was doing at the beginning. I use that new form validation class to validate the form I´m running. Maybe a simpler approach would be to add everythign to the form (while using the standard form validation class) and instead of add slots to the form, you delete them - although I´m not sure if that´s possible but it should be, imo -

1 Like

oh. i see. thanks.