Hello, I have a question about how to reply to the options in the form. This is the dialogue I hope to complete.
user: I would like to book a hotel near McDonald’s.
bot(Query the database and return to the hotels near McDonald’s): Please select a hotel to book:Four Seasons Hotel & Hilton Hotel & Greentree Hotel
user: Four Seasons Hotel
bot: Please enter the check-in time
user: 2020.05.01 12:10
bot: Please enter room type
user:Standard room
bot:Successful booking!
actions.py about book_hotel:
class BookHotel(FormAction):
def name(self):
return "form_book_hotel"
def required_slots(tracker: Tracker) -> List[Text]:
"""A list of required slots that the form has to fill"""
return ["hotel_name", "location", "room_type", "date_checkin"]
@staticmethod
def slot_mappings(self) -> Dict[Text, Union[Dict, List[Dict]]]:
"""A dictionary to map required slots to
- an extracted entity
- intent: value pairs
- a whole message
or a list of them, where a first match will be picked"""
return {
"hotel_name": self.from_entity(entity="hotel", intent="entity_intent"),
"date_checkin": self.from_entity(entity="date", intent="entity_intent"),
}
def submit(self, dispatcher: CollectingDispatcher, tracker: Tracker,
domain: Dict[Text, Any], ) -> List[Dict]:
"""Define what the form has to do
after all required slots are filled"""
dispatcher.utter_message("Successful booking!")
return [AllSlotsReset()]