Hello.
I am trying to validate a username slot by looking in a database if it exists. The query works well and outputs as expected.
This is the relevant method of my FormValidationAction:
async def validate_username(self, value, dispatcher, tracker, domain):
username = value.lower()
db = DatabaseConnection()
count = db.count('user_info', f"Username = '{username}'")
db.disconnect()
if count == 1:
return {'username', username}
else:
utterance = get_utter_from_lang(
tracker,
'Sorry, {} is not a registered user.'.format(username),
'Désolé, {} n\'est pas un utilisateur enregistré.'.format(username),
'عذرًا، {} ليس مستخدمًا مسجلاً'.format(username),
'Ներողություն, {} - ը գրանցված օգտվող չէ:'.format(username)
)
dispatcher.utter_message(utterance)
return {'username', None}
So, if the username is found in the database, count is equal to 1 and the username slot should be set with the given value. If the username was not found, count is equal to 0, so username should be set to None (or null), and the bot asks for the username again.
But, in both cases, I get this error on the action server:
E:\...\_venv\lib\site-packages\rasa_sdk\forms.py:858: UserWarning: Cannot validate `password`: make sure the validation method returns the correct output.
warnings.warn(
and the bot sets the slot and continues the form anyway.
I don’t know if it’s relevant, but that’s how it’s defined in domain.yml:
forms:
form_query_quota:
username:
- intent_name: None
not_intent: stop
type: from_text