Rasa 2.0 and required slots conditional logic?

I’m excited to use 2.0, and have a question about required slots and using conditional logic.

I use a lot of logic in my required_slots methods in my forms that change what is required based on the user’s answers. Here’s an example:

    def required_slots(tracker: Tracker) -> List[Text]:
        if (tracker.get_slot("fatal_sql_error") is None ):
            requiredSlot = ["fatal_sql_error", "attempt_to_register"]
            return requiredSlot
        elif (tracker.get_slot("fatal_sql_error") == "No" ):
            print("collect error / ticket")
            if (tracker.get_slot("attach_screenshot",) is None):
                requiredSlot = ["attach_screenshot","error_message"]
                return requiredSlot
                return []
            if (tracker.get_slot("attempt_to_register") is None):
                requiredSlot = ["attempt_to_register"]
                return requiredSlot
            elif (tracker.get_slot("attempt_to_register") == "No"):
                requiredSlot = ["logged_in_60_days"]
                return requiredSlot
                if (tracker.get_slot("need_help_changing_password") is None):
                    requiredSlot = ["need_help_changing_password"]
                    return requiredSlot
                elif (tracker.get_slot("need_help_changing_password") == "No"):
                    return []
                    requiredSlot = ["afloat_resolved"]
                    return requiredSlot

I’m not sure I see how I can mimic that logic with the new .yml format in the forms: section mentioned here - Forms

Is that type of logic possible with 2.0? or do you have any other suggestions?

I think you can do this in a validation function. See Requesting Extra Slots.


That looks like it’ll work, thank you.

I’ll do some experimenting to see if I can get it working and mark your reply as the solution. I’m guessing in my case, I’ll be utilizing this a lot.

It is possible to have several entities and get one of this? for example

- intent: navigation
  examples: |
    - navigate to [home](location)
    - start navigation to my [work](location)
    - [street 98](address) navigate
    - take me to [berlin](city)
    - navigate to [paris](city)

I want to have one of this in my form rules: forms: navigation_form: required_slots: place_to_navigate: - type: from_entity entity: location

right now i can only have location, is any way to take either location, city, address, etc, is this possible? Sorry I’m new and if I can do it avoidng phyton would be better (I’m android dev, I don’t know much about python) Thanks a lot

Yes you can create nlu data like that and have different entities set in different ways. It actually make it more robust like this.

Were you able to get it to work?