I’m writing an appointment bot. This bot connects to a backend to book appointments the user requested. Now there are multiple cases that might happen:
Everything is fine the appointment is succesfully booked
The requested time is not within the opening times
The requested time slot is already occupied
etc…
Based on that I want to lead the conversation into different directions, I see two ways to do this.
Let the backend return a slot filling event that fills an book_status slot and train rasa core to take this into account
Let the server return a force followup action event
A disadvantage of the second method is that my conversation logic would be divided between my backend and rasa core. Also I have no Idea how rasa would handle being thrown out of it’s normal flow like this.
Does anyone else has some pros and cons for these methods?
I recommend using the FormAction for this, FormActions are described in the Slot Filling topic of documentation.
In short, you should define a form of slots required to complete your appointment. After each response, you can validate, if user value is acceptable (check, if it is inside working hours, if slot is free etc.), in docs it is shown how to request an correction if validation fails (with custom logic). After all slots get through fine, you can easily submit (create appointment), with ease. Cheers!
I agree with @Kyras, in fact, I’m working on a similar use case and I use FormActions to to this. I have different required slots like date, time, ID etc which handle this. For every slot I use the validate method to check . For example, if a person types in a time which has already been booked (I get the list of booked timings from my backend database), I prompt them to choose a different time (all this using conditions in the validate function) and similarly for the other slots like date.
Alternatively, you can override the next_slot() method to show the user only the list of available timings (fetched from your backend) by using utter_template() while asking for the required slots.