FormAction multiple validation fail handling

Hello, I have a form action in which i have validation for a slot (phone number). If user inputs value in wrong format multiple times, i want my bot to stop asking for correct value again, but to continue with different path instead.

In short: i’d like to translate multiple slot-validation fail into specific intent.

What is the best way to do that?

Not the best way, but one way could be to keep a fill_count_slot and increasing it if the validation fails (you can set other slots as well) and once it reaches a desired value, pass the validation and set it back to zero.

Thank you for response saurabh!. What do you mean by ‘pass the validation’? How?

I’m doing this now:

def validate_phone(self, value, dispatcher, tracker, domain):
    if self.isCorrect(value):
            # validation succeeded, set the value of the "cuisine" slot to value
            return {"phone": value}
        else:
            self.number_of_errors = self.number_of_errors + 1

            if self.number_of_errors > 1:
                self.number_of_errors = 0
                raise ActionExecutionRejection(self.name(), "too bad")

            dispatcher.utter_message(template="utter_wrong_phone")
            # validation failed, set this slot to None, meaning the
            # user will be asked for the slot again
            return {"phone": None}

I don’t know how to translate raised ActionExecutionRejection to an intent.

1 Like