Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
def validate(self,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict]:
"""Validate extracted requested slot
else reject the execution of the form action
# extract other slots that were not requested
# but set by corresponding entity
slot_values = self.extract_other_slots(dispatcher, tracker, domain)
# extract requested slot
slot_to_fill = tracker.get_slot(REQUESTED_SLOT)
if slot_to_fill:
tracker, domain))
if not slot_values:
# reject form action execution
# if some slot was requested but nothing was extracted
# it will allow other policies to predict another action
raise ActionExecutionRejection(,
"Failed to validate slot {0}"
"with action {1}"
# we'll check when validation failed in order
# to add appropriate utterances
for slot, value in slot_values.items():
if slot == 'num_people':
if not self.is_int(value) or int(value) <= 0:
# validation failed, set slot to None
slot_values[slot] = None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment