Yes I totally understand from your side.
This is my FormValidationAction
simplified:
class ValidateFormLogIn(FormValidationAction):
def name(self):
return 'validate_form_log_in'
async def required_slots(self, predefined_slots, dispatcher, tracker, domain):
# predefined_slots = ['password', 'username']
# Doing that because Rasa X sorts them alphabetically
return [predefined_slots[1], predefined_slots[0]]
async def validate_username(self, value, dispatcher, tracker, domain):
# Check if username exists in the database
return {'username': username}
# else
return {'username': None}
async def validate_password(self, value, dispatcher, tracker, domain):
# Check if password matches with the database
return {'password': secret, 'loggedin': True, 'password_tries': 0}
# else
return {'password': None, 'loggedin': False, 'password_tries': password_tries+1}
I want the form to stop after 3 wrong attempts, so I created a password_tries
slot that increases inside the validate_password()
method.
I want to exit the form if that happens, so I added:
async def run(self, dispatcher, tracker, domain):
if tracker.get_slot('password_tries') >= 3:
return [ActiveLoop(None), SlotSet('requested_slot', None), SlotSet('username', None), SlotSet('password', None), SlotSet('login_type', None), SlotSet('password_tries', 0)]
await super().run(dispatcher, tracker, domain)
But after doing that, the FormValidationAction
stops working.
It starts asking for the password before the username, and validate_username()
and validate_password()
do not work/run.
There are print()
s inside the methods, and they’re not appearing in the Action Server logs.
It’s as if the ValidateFormLogIn
class didn’t exist.
You also added ActiveLoop(None)
in the return
of run()
, but this is not an event listed here.
Is it in rasa.core.events
?