def validate_dob( self, value: Text, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict[Text, Any], ) -> Dict[Text, Any]: reg_string = "^[0-3]?[0-9]/[0-3]?[0-9]/(?:[0-9]{2})?[0-9]{2}$" intent_confidence = tracker.latest_message.get("intent", {}).get("confidence") intent = tracker.latest_message.get("intent", {}).get("name") if intent in self.reject_intents and intent_confidence > 0.95: return {"dob": None} if re.search(reg_string, value): return {"dob": value.strip()} else: logger.debug("dob error") dispatcher.utter_message( text= "Sorry, i didn't get you.\nPlease provide the DOB in valid format" ) return {"dob": None}
def request_next_slot( self, dispatcher: "CollectingDispatcher", tracker: "Tracker", domain: Dict[Text, Any], ) -> Optional[List[EventType]]: #track intent of the input intent = tracker.latest_message.get("intent", {}).get("name") intent_confidence = tracker.latest_message.get("intent", {}).get("confidence") print(intent) #classify deacitvate intent if intent == 'deactivate': return [BotUttered("Do you really want to exit?", tracker)] #affirm intent to refill form elif intent == 'affirm' and intent_confidence > 0.95: return [self.deactivate()] ## continue filling form but other intents are else: for slot in self.required_slots(tracker): if self._should_request_slot(tracker, slot): logger.debug("Request next slot '{}'".format(slot)) dispatcher.utter_template("utter_ask_{}".format(slot), tracker, silent_fail=False, **tracker.slots) return [SlotSet(REQUESTED_SLOT, slot)]
def required_slots(tracker): logger.debug(tracker.current_slot_values()) print("Slot mappings: ",tracker.current_slot_values()) return [ "name", "dob", "phone", "email", "job_preference" ]