How "required_slots" is executed? - Dynamic form behavior

In the restaurant example provided in the docs, I have a doubt.

class ValidateRestaurantForm(FormValidationAction):
    def name(self) -> Text:
        return "validate_restaurant_form"

async def required_slots(
    self,
    slots_mapped_in_domain: List[Text],
    dispatcher: "CollectingDispatcher",
    tracker: "Tracker",
    domain: "DomainDict",
) -> Optional[List[Text]]:
        additional_slots=[]
        if tracker.slots.get("outdoor_seating") is True:
            additional_slots.append("shade_or_sun")
        return required_slots

async def extract_shade_or_sun(
    self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict
) -> Dict[Text, Any]:
    text_of_last_user_message = tracker.latest_message.get("text")

    return {"shade_or_sun": text_of_last_user_message}

To the best of knowledge I know that required_slots is executed every time any form event is being performed (form initiation, validation, Rejection). So in the above code (as provided in doument Rasa Forms), when User sends a response for utter_ask_outdoor_seating with a confirmation response (yes). Rasa core first executes required_slots method which it then thinks that it needs to extract shade_or_sun slot.

The following are my questions -

  1. Now right after this, its executes the method extract_shade_or_sun as it is in the required_slots without utter_ask_shade_or_sun being uttered first.
  2. In case if there was method for validation of slot outdoor_seating, even in that scenario required_slots is executed first, then validation of outdoor_seating, and the next requested slot is set to shade_or_sun and extraction of it is performed.

Am i missing something here. need help very bad

Hi @vagi8,

I recommend that you test the bot in debug mode, like this:

rasa shell --debug

which prints out exactly the steps that the bot goes through to process a user sentence.

If you then put print statements in the required_slots and extract_shade_or_sun methods, you can see exactly when these methods are called.