How to reask for slot after executing the submit method of a formaction

Hey there :slight_smile:

I’m currently working on an appointment bot using a form action to request different information. Once all requested slots are gathered, I want to run the submit method and check if there is an open time slot available for the user given the provided information. If there is e.g. no time slot available with the given information, I want to reask for another date or time. However, I couldn’t find any information how one can reask for slots after executing the submit method. I know that we can set specific slots to ‘None’ (in the validation function) in order to make a form reask for the slot. How is this handled at the end of a form i.e. after the submit method? Is this handled in the training stories?

Any help is appreciated :slight_smile:

hi @nklmlchr - welcome to the forum! Yes, that’s right, the easiest way to do this is to set the slot to None, and then make sure the form is re-run again. A story is probably the easiest way to do that (I would use interactive learning to create the story rather than write it out by hand)

Hey Alan, thanks for the quick reply :slight_smile: How would you re-run a form within a story given the example story below? Couldn’t find any resources regarding this.

## book_appointment_form + apptime no longer available
* book_app_info
 - utter_ask_symptoms
* deny
 - doctor_appointment_form
 - form{"name": "doctor_appointment_form"}
 - slot{"name": "Hans Franz"}
 - slot{"appday": "2020-08-04"}
 - slot{"apptime": "08:00"} 
<! All slots are filled upon this point. Dummy example: An 08:00 appointment is not longer available -> form needs to re-run after submit method>

My submit functions looks like this:

async def submit(self, dispatcher: "CollectingDispatcher", tracker: "Tracker", domain: Dict[Text, Any]) -> List[Dict]:
        if '8' in tracker.get_slot('apptime'):
            # form needs to reask for app time
            return [SlotSet('apptime', None)]
        else:
            return []

wait, actually there might be an easier way to do this. When are you doing the API call where you check the availability? Maybe you could have that in the validate method for the appointment time, and just not set the apptime slot of that time isn’t actually available

Thought of this as well, but I can only make an API call when all slots are filled at the end of the form. In the actual form I request further slots like doctors_name, reason etc. and I need to check the availability with the information from all requested slots. My understanding would be that I would make the API call in the submit function and if there is no appointment available I would reask the user for another apptime or appday or doctors_name.