Problems of inputting user data to mysql

First of all, sorry for my poor English.

For my project, I want to let the user input their name and password to store their data. I am now planning to use forms to do the check slots. My problems here is the data validation always interrupted and detected to be another intent. I don’t know if my rules setting are right or not. And I want to know how to train it to let it understand the user input is belongs to username and password cause the users can just simply type some random characters as the username and password.

And also I saw different version of setting the actions.py. I don’t know which is suitable for me. My rasa version is 3.4.0.

here is the rule in rules.yml

- rule: register

steps:

  • intent: new_yes

  • action: user_login

  • active_loop: user_login

  • active_loop: null

  • slot_was_set:

    • requested_slot: username
  • slot_was_set:

    • requested_slot: password
  • slot_was_set:

    • requested_slot: null
  • active_loop: null

  • action: add_user

  • action: utter_gettype

def validate_username(self, slot_value: Any, dispatcher: CollectingDispatcher, tracker: Tracker, domain:DomainDict) -> Dict\[Text, Any\]:

    

    name = str(slot_value)

    new = tracker.get_slot('new')

    try:

        connect= mysql.connector.connect(host="localhost",user="root",password="",database="restaurant")



        if connect.is_connected:

            cursor = connect.cursor(dictionary=True)

            query = "SELECT username FROM user WHERE username = %s"

            cursor.execute(query,(name,))

            row = cursor.fetchall()



            if not all(char.isalpha() for char in name):

                dispatcher.utter_message("name should be english")

                return {"username": None}



            elif new:



                if len(row) == 0:

                    return {"username": name}

                else:

                    dispatcher.utter_message("name was used")

                    return {"username": None}

            else:

                if len(row) == 0:

                    dispatcher.utter_message("wrong name, please input again")

                    return {"username": None}

                else:

                    return {"username": name}



            

    except Error as e:

        dispatcher.utter_message("error_checkname")



    return \[\]

here is the part of the class ValidateUserLogin