I am trying to find out how to work with ValidationAction. It works fine when I only want to validate one slot buf if I want to validate more than one it crashes. I have a slot “checkin_date_dummy” that I use to extract information from Duckling. If Duckling returns a date range, then I want to fill the “checkin_date” and “checkout_date”, otherwise just the “checkin_date” slot.
I am also trying to figure out how to set slot values in custom actions, because this way I could simply update the slot values and would only return a single slot in the return statement.
class ValidatePredefinedSlots(ValidationAction):
def validate_checkin_date_dummy(
self,
slot_value: Any,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: DomainDict,
) -> Dict[Text, Any]:
"""Validate checkin_date_dummy."""
# DucklingEntityExtractor returns a dict when it extracts a date range
if isinstance(slot_value, dict):
print("Is dict:")
#tracker.set_slot("checkout_date", get_date(slot_value.get("to"))) ### FIX: 'Tracker' object has no attribute 'set_slot'
#SlotSet("checkout_date", get_date(slot_value.get("to"))) ### FIX: This crashes
return {"checkin_date": get_date(slot_value.get("from"))}
#return {"checkout_date": get_date(slot_value.get("to"))}
#return {"checkin_date": get_date(slot_value.get("from")),
# "checkout_date": get_date(slot_value.get("to"))}
#return [SlotSet("checkin_date", get_date(slot_value.get("from"))),
# SlotSet("checkout_date", get_date(slot_value.get("to")))]
else:
# DucklingEntityExtractor returns a string for a single date/time
print("is no dict")
return {"checkin_date": get_date(slot_value)}
#return SlotSet("checkin_date", get_date(slot_value))```