I have a form that uses duckling to extract two dates, minDate and maxDate. Everyting works pretty well, except when the user feel like he or she entered a date wrong and tries to fill it with a new value.
Say that a user first fills the minDate slot and then realize it was the wrong date and tries to fill it again. Normally a form would overwrite minDate but in my case the re-entered dates gets placed in the maxDate. I feel i could sove this with slot mappings but can get it right.
My current FormAction:
class ActionRequestVacation(FormAction):
"""Example of a custom form action"""
def name(self) -> Text:
return "vacation_form"
@staticmethod
def required_slots(tracker: Tracker) -> List[Text]:
return ["minDate", "maxDate"]
def validate_minDate(self,value: Text,dispatcher: CollectingDispatcher,tracker: Tracker,domain: Dict[Text, Any],) -> Optional[Text]:
if type(tracker.get_slot("time")) is dict:
SlotSet("minDate", tracker.get_slot("time")['from'])
return { 'minDate': tracker.get_slot("time")['from'] }
else:
SlotSet("minDate", tracker.get_slot("time"))
return { 'minDate': tracker.get_slot("time") }
def validate_maxDate(self,value: Text,dispatcher: CollectingDispatcher,tracker: Tracker,domain: Dict[Text, Any],) -> Optional[Text]:
if type(tracker.get_slot("time")) is dict:
SlotSet("maxDate", tracker.get_slot("time")['to'])
return { 'maxDate': tracker.get_slot("time")['to'] }
else:
SlotSet("maxDate", tracker.get_slot("time"))
return { 'maxDate': tracker.get_slot("time") }
def slot_mappings(self) -> Dict[Text, Union[Dict, List[Dict]]]:
return {
"minDate": self.from_entity(entity="time"),
"maxDate": self.from_entity(entity="time")
}
def submit(self,dispatcher: CollectingDispatcher,tracker: Tracker,domain: Dict[Text, Any],) -> List[Dict]:
print(tracker.get_slot("time"))
dispatcher.utter_message()
return []
How can i solve this?
Thanks!