Hello,
I am working on appointment setting bot. So I have a form to input date, time , email , phone from user and set an appointment. I also want that the bot will give them option to select event they want to set appointment for.
Is there a way I can provide options for selecting event type which is returned from the calendar based on the event user has created. For example the conversation will be like this:
User: Set an appointment
Bot : please enter the event type you want to attend: IntroToProduct ,MarketingMeeting , Someevent3 (These events are retrieved from the calendar app based on the event user has created)
User : IntroToProduct
Bot: thanks, what day you want to come in.
User: Monday
. . . What do I need to change in my from action to first get the event and display those before proceeding to ask day
Here is my action appointment_form class
class ActionAppointment(FormAction):
def name(self):
return 'appointment_form'
@staticmethod
def required_slots(tracker: Tracker) -> List[Text]:
return ["apdate", "aptime","email","phone"]
def slot_mappings(self):
return {"apdate": self.from_entity(entity="apdate",not_intent="hours"),
"aptime": self.from_entity(entity="aptime",not_intent="chitchat"),
"email": self.from_entity(entity="email",not_intent="chitchat"),
"phone": self.from_entity(entity="phone",not_intent="chitchat")}
def validate_aptime(self,value: Text,dispatcher: CollectingDispatcher,tracker: Tracker,domain: Dict[Text, Any])-> Optional[Text]:
"""check time and validate appointment type"""
base_url="https://myserver.com/api/calendar/checktime"
payload = {'sender': tracker.current_state()['sender_id'], 'date': tracker.get_slot('apdate'), 'time': value}
resp = requests.post(base_url, data=payload)
data = resp.json()
mess = data['message']
isfree = data['isfree']
if isfree:
return value
else:
dispatcher.utter_message(mess)
return None
def submit(self,dispatcher: CollectingDispatcher,tracker: Tracker,domain: Dict[Text, Any]):
dispatcher.utter_template('utter_appointment_success', tracker)
return []