Duckling entity not validating on activation of form

Hi! I have a bit of a problem, I have a form which extracts 2 dates with duckling. I use the validate_{slot} method to move the duckling time-dimesion to another slot. All this works unless a date is provided in the same message that triggers the form, if that is the case the validate function is never called. Why is that and how can i solve it?

Actions.py:

class ActionRequestVacation(FormAction):

    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]:
        print("validate_minDate")
        print(tracker.get_slot("time"))
     
        if type(tracker.get_slot("time")) is dict:
            return { 'minDate': tracker.get_slot("time")['from'] }
        else:
            return { 'minDate': tracker.get_slot("time") }

    def validate_maxDate(self,value: Text,dispatcher: CollectingDispatcher,tracker: Tracker,domain: Dict[Text, Any],) -> Optional[Text]:
        print("validate_maxDate")
        print(tracker.get_slot("time"))
        
        
        if type(tracker.get_slot("time")) is dict:
            return { 'maxDate': tracker.get_slot("time")['to'] }
        else:
             return { 'maxDate': tracker.get_slot("time")}

    def slot_mappings(self) -> Dict[Text, Union[Dict, List[Dict]]]:
        console.log("in slot_mappings")
        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]:

        dispatcher.utter_message()
        return []

Thanks!

You can only fill slots, that have the same name as the entity before the form starts. This is also true for the initial message.

Here’s the code

If you type non-range answers (like “tomorrow”), you should get the same value for min and max date, don’t you?

Yes, I have some work to do. So there is no way to extract time from the initial message?

Thanks!

You could define a ‘validate_time’-method and set both slots if you encounter a time-range.

Yes I have acctually tried to have a ‘validate_time’ but it doesn’t seem to work, it never gets called. Also this doesnt help me with extracting time on the initial message?

Post the code. How you know, it never gets called?

If i add this:

def validate_time(self,value: Text,dispatcher: CollectingDispatcher,tracker: Tracker,domain: Dict[Text, Any],) -> Optional[Text]:
        print("validate_time")
        return {}

the action server never prints validate_time

You won’t see any ‘print’ statement at all from the action-server. Use the logger with the appropiate level (in your case DEBUG) and start the actions server with the option -vv. You’ll should find that statement in the logs.

But I can see print statements from validate_minDate. I can check in the same window from where i started the action-server.

Ah, its not in the required slots list. Add it or it won’t be called.