Unable to detect validation

@nik202

Hello,

I am having an issue detecting validation for a form. When I do rasa shell, the validation does not happen. Here is my actions.py code.

from typing import Any, Text, Dict, List, Union

from rasa_sdk import Action, Tracker, FormValidationAction
from rasa_sdk.executor import CollectingDispatcher
from rasa_sdk.events import EventType
from rasa_sdk.forms import FormAction
from rasa_sdk.types import DomainDict
import re

#from csv_data_store import DataStore

## -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
import pandas as pd
import os

from sqlalchemy import false

def DataStore(name,gender,occupation,age):
    #if there is a file called user_data.csv then add to it
    if os.path.isfile("user_data.csv"):
        df=pd.read_csv("user_data.csv")
        df=df.append(pd.DataFrame([[name,gender,occupation,age]],
                        columns=["name","gender","occupation","age"]))
        df.to_csv("user_data.csv",index=False)
        #if for a reason its not there then create one from scratch.
    else:
        df=pd.DataFrame([[name,gender,occupation,age]],
                        columns=["name","gender","occupation","age"])
        df.to_csv("user_data.csv",index=False)
    return []


## -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

## beginning of new code that helps run the csv file.
#
#
#

class ActionSaveData(Action):

    def name(self) -> Text:
        return "action_save_data"

    def run(self, dispatcher: CollectingDispatcher,
            tracker: Tracker,
            domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
        DataStore(tracker.get_slot("name"),
            tracker.get_slot("gender"),
            tracker.get_slot("occupation"),
            tracker.get_slot("age"))
        dispatcher.utter_message(text="Thank you for taking the time. How can I help you today? Please type your question below. All questions should be related to COVID-19 for example: What is COVID-19?")

        return []

class FormDataCollect(FormAction):
    def name(self) -> Text:
        return "info_form"

    @staticmethod
    def required_slots(tracker: "Tracker") -> List[Text]:
        return ["name","gender","occupation","age"]

    def slot_mappings(self) -> Dict[Text, Union[Dict, List[Dict[Text, Any]]]]:
        return {
            #if you use from_entity, it will extract information from the entity.
            #if you take the info from the text then it will fill the slot with the next info the person types in.
            "name":[self.from_text()],
            "gender":[self.from_text()],
            "occupation":[self.from_text()],
            "age":[self.from_text()]
        }

        self.fr

    def submit(
        self,
        dispatcher: "CollectingDispatcher",
        tracker: "Tracker",
        domain: Dict[Text, Any],
    ) -> List[EventType]:

        # dispatcher.utter_message("Here are the information that you provided.\nName: {0},\nGender: {1},\nOccupation: {2}, \nAge: {3}".format(
        #     tracker.get_slot("name"),
        #     tracker.get_slot("gender"),
        #     tracker.get_slot("occupation"),
        #     tracker.get_slot("age") 
        #     ))

        # dispatcher.utter_message("Success!")

        return []

## End of code that helps to save the csv.
#
#
## -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
#
#
# Form Validation Class.
## -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

class ValidateInfoForm(FormValidationAction):
    def name(self) -> Text:
        return "validate_info_form"


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

        # slot_name = Tracker.get_slot("name")
        # this function checks the length of the name and the characters
        bol = re.match(r"^[\-'a-zA-Z ]+$", slot_value) is not None
        if len(slot_value)<2 or len(slot_value)>26 or bol == False:
            dispatcher.utter_message("There seems to be a problem!")
            dispatcher.utter_message("Name lenght should be between 2-26 Characters and Name should not have any special characters  or numbers.")
            dispatcher.utter_message("Please try again!")
            return{"name": None}
        else:
            return {"name": slot_value}

Rasa Version

(rasaenv) C:\Users\Atwine\Desktop\RaSa IDI Project\idi-chatbot v2>rasa --version
Rasa Version      :         2.8.1
Minimum Compatible Version: 2.8.0
Rasa SDK Version  :         2.8.1
Rasa X Version    :         0.39.3
Python Version    :         3.8.3

domain

version: '2.0'
config:
  store_entities_as_slots: true
session_config:
  session_expiration_time: 60
  carry_over_slots_to_new_session: true
intents:
- greet:
    use_entities: true
- what_can_you_do:
    use_entities: true
- thank_you:
    use_entities: true
- goodbye:
    use_entities: true
- affirm:
    use_entities: true
- deny:
    use_entities: true
- faq:
    use_entities: true
- chitchat:
    use_entities: true
- contact_us:
    use_entities: true
- outofscope:
    use_entities: true
- inform:
    use_entities: true
- goodbye.:
    use_entities: true
- inform_location:
    use_entities: true
entities:
- name
- gender
- occupation
- age
- language
- disease
- symptoms
- email
- location
slots:
  name:
    type: rasa.shared.core.slots.TextSlot
    initial_value: null
    auto_fill: true
    influence_conversation: true
  gender:
    type: rasa.shared.core.slots.TextSlot
    initial_value: null
    auto_fill: true
    influence_conversation: true
  occupation:
    type: rasa.shared.core.slots.TextSlot
    initial_value: null
    auto_fill: true
    influence_conversation: true
  age:
    type: rasa.shared.core.slots.TextSlot
    initial_value: null
    auto_fill: true
    influence_conversation: true
  requested_slot:
    type: rasa.shared.core.slots.UnfeaturizedSlot
    initial_value: null
    auto_fill: true
    influence_conversation: false
  location:
    type: rasa.shared.core.slots.UnfeaturizedSlot
    initial_value: null
    auto_fill: true
    influence_conversation: false
responses:
  utter_ask_name:
  - text: How may I refer to you please? Please type your name e.g Jane or initials e.g AMT
  - text: How may I adress you? Please type your name e.g Jane or initials e.g AMT
  utter_ask_age:
  - text: 'What is your age, Please type a number e.g: 24'
  - text: How old are you? Please type a number below. e.g 35
  utter_ask_occupation:
  - text: 'What is your occupation, Please type below:, eg: doctor?'
  - text: What do you do for a living? Please type below, e.g doctor.
  utter_ask_gender:
  - text: 'What is your Gender: Please type: Male or Female.'
  utter_anything_else:
  - text: Is there anything else I can assist you with?
  - text: What else can I help you with?
  - text: Anything else I can help you with?
  - text: What else can I do for you?
  utter_what_is_your_location:
  - text: Where are you located right now?
  - text: Where are you reaching us from please?
  - text: Where do you live?
  utter_what_can_you_do:
  - text: I am built to inform you about COVID-19. What would you like to know.
  - text: I am built to support the current COVID-19 pandemic. How can I help.
  - text: I know stuff about covid. Ask away.
  - text: Built to support COVID-19 questions. What would you like to know?
  utter_thank_you:
  - text: Thank you very much.
  - text: Thanx
  - text: Thank you.
  utter_thank_you_response:
  - text: You are welcome.
  - text: Don't mention it.
  - text: Glad to be of help.
  - text: Sure thing, happy to help
  - text: Uh huh
  - text: Glad to be of help
  - text: Sure thing.
  utter_greet:
  - text: Hey! I am your COVID-19 virtual assistant.
  - text: Hello!, I am your COVID-19 virtual assistant
  utter_greet_follow_up:
  - text: |-
      I am able to answer some of your questions about COVID-19. 
      I am currently learning and I don't yet have all the answers to your questions. 
      I understand better when there is only one question and when the questions are short. 
      Thank you for your understanding.

      Please take time to answer a few questions, It will take less than a minute.
  - text: |-
      I am able to answer some COVID-19 questions.
      I may not answer all questions accurately as I am still under development.
      Good news is, I get better and learn from our conversation.
      Let's get started!

      To better serve you, please answer the following questions. It will take only a minute!.    
  utter_how_to_assist:
  - text: How can I help you today {name}?
  - text: Great, how can I assist you {name}?
  - text: Hey {name}, how can I help?
  - text: Hi {name}, I am at your service, how can I assist?
  - text: Cheers {name}, how can I help?

actions:
- validate_contact_us_form
- action_submit_contact_us_form
- utter_thank_you
- utter_thank_you_response
- action_save_data
- info_form
- validate_info_form
forms:
  info_form:
    required_slots: {}
e2e_actions: []

What could I be missing in this implementation. config.yml (1.1 KB) endpoints.yml (1.4 KB) stories.yml (11.8 KB)

Are you also running the action server on a different terminal ?

Yes, the server is running in a different terminal. @jusce17

@atwine sorry for the late response, can you try to update this in domain.yml

forms:
  info_form:
    name:
    - type: from_text

delete the older trained model and re-train, please.

Thanks.

@nik202

Thanks Nik, but its still not responding. What else can I try.