Problem Deactivating the form

I need to implement a functionality where user needs to log in from the chatbot (this is a must.) by providing username and password, After which the user will be able to access data available for that user(probably from the database).

I am implementing this using forms and slots. However, the problem is I want the form to deactivate after n wrong username/pass inputs. The way I am approaching this problem is by using validate_username and validate_password methods, I take static count variables and return self.deactivate() if it user enters wrong username n number of times. But this doesn’t deactivate the form, instead it only deactivates that validation method itself, after which the form moves on to fill other slot like password(when It should’ve deactivated.).

I am getting this in action logs — Returning values in helper validation methods is deprecated. Your validate_emp_code() method should return a dict of {‘slot_name’: value} instead.

Any Idea on how can I make the form deactivate after user inputs wrong value for the slot lets say 2 times? Below is the code of one of the validation method I’m using for better idea.

def validate_emp_code(
        value: Text,
        dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: Dict[Text, Any]) -> Dict[Text, Any]:
        """Validate emp_code value."""

        if LoginForm.emp_count < 1:
            if value in self.emp_code_db():
                #validation succeeded, set the value of the "emp_code" slot to value
                return {"emp_code": value}
                LoginForm.emp_count += 1
                return {"emp_code": None}
            LoginForm.count = 0
            message = 'Login Unsuccessful.'
            dispatcher.utter_message(text = message)
            return [self.deactivate()]

Screenshot (1)

(It should deactivate the form after login unsuccessful message, however it keeps on filling other slots.)

hi @rhythmsaparia - the financial demo bot (2.0 branch) has an example that should be helpful.

1 Like

Thank you @amn41