Rasa Form multiple duckling dates, overwrite allready fille slots

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!

This is defintiely a difficult case! Can you provide an example of a conversation where this might happen? I’m guessing from your slot mappings you’re trying to handle both from and to in the same sentence, as well as separately.

Yes, i try to handle them separately as well as in the same sentence.

Here is an example of when this occures:

Your input ->  i need a vacation                                                                                                                                                                                   
Okay!
When do you plan to leave?
Your input ->  the 5th                                                                                                                                                                                             
When will you be back at work?
Your input ->  actually, i plan to leave the 7th                                                                                                                                                                   
The form parameters are:
 - minDate: 2020-04-05T00:00:00.000+02:00
 - maxDate: 2020-04-07T00:00:00.000+02:00

When i write “actually, i plan to leave the 7th” the minDate should be overwritten instead of filling maxDate. And i know that the nlu knows that minDate should be filled when i write “actually, i plan to leave the 7th” but still this happens.

Thanks for the help!

Do you have any advice?

What if you setup a separate mindate intent that would capture utterances with leave and similar words and set the minDate based upon duckling’s date and the intent.