Reset slots during form validation

Hi all,
I would like to know how I could reset slots during form validation.
I am trying to validate the slot pizza_type by:

class ValidateStandardForm(FormValidationAction): 
  def name(self) -> Text:
       return "validate_standard_form" 

   def validate_pizza_type(self,   
                            slot_value: Any,
                            dispatcher: CollectingDispatcher,
                            tracker: Tracker,
                            domain: DomainDict) -> List[Dict[Text, Any]]:

    pizza_type_db = ['salami', 'tuna', 'wurstel', 'pepperoni']
    slot_pizza_type = tracker.get_slot("pizza_type")
    flag = 0
    for pizza in slot_value:
        if pizza not in pizza_type_db:
            flag = 1
            dispatcher.utter_message(f"!!!{pizza} is not a valid pizza type!!!")
    if flag == 1:
        return [SlotSet("pizza_type", []), SlotSet("pizza_quantity", [])]
        return [{"pizza_type": slot_pizza_type}]

I have noticed that is not possible to reset the slots pizza_type and pizza_quantityusing SlotSet(), also the action server gives this warning message:

UserWarning: Cannot validate `pizza_type`: make sure the validation method returns the correct output.
  f"Cannot validate `{slot_name}`: make sure the validation method "

First, you use the format {slot: value} in slot validation and [SlotSet(slot, value)] in run().

If you want to unset a slot in run(), use None with SlotSet():

if flag == 1:
    return [SlotSet("pizza_type", None), SlotSet("pizza_quantity", None)]
    return [SlotSet("pizza_type", slot_pizza_type)]

If you want to unset a slot in validation, use a dictionary:

if flag == 1:
    return {"pizza_type": None, "pizza_quantity": None}
    return {"pizza_type": slot_pizza_type}
1 Like