Cannot Validate Slot


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}'")

        if count == 1:
            return {'username', username}

            utterance = get_utter_from_lang(
                'Sorry, {} is not a registered user.'.format(username),
                'Désolé, {} n\'est pas un utilisateur enregistré.'.format(username),
                'عذرًا، {} ليس مستخدمًا مسجلاً'.format(username),
                'Ներողություն, {} - ը գրանցված օգտվող չէ:'.format(username)
            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\ UserWarning: Cannot validate `password`: make sure the validation method returns the correct output.

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:

    - intent_name: None
      not_intent: stop
      type: from_text

You are currently returning sets rather than dicts since you have used commas instead of colons. Validation actions must return dictionaries.

1 Like

I am so dumb, I did not notice that. Thank you!

1 Like