Form Action: slot validation not working

Hi Team,

I am getting below error for slot validation part. utter_wrong_slot is not working.

rasa_sdk.endpoint - Failed to extract slot domain with action onboard_form.

def validate_domain( self, value: Text, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict[Text, Any], ) -> Optional[Text]: “”“Validate domain value.”""

    if value.upper() in ['SALES','FINANCE','ADMIN']:
        # validation succeeded, set the value of the "domain" slot to value
        return {"domain": value}
    else:
        dispatcher.utter_template("utter_wrong_domain", tracker)
        # validation failed, set this slot to None, meaning the
        # user will be asked for the slot again
        return {"domain": None}

Please guide me if I have to modify my function to validate.

form failed to extract anything form the input, it’s hard to say what is wrong, but it might be that your slot_mapping are not set properly

@Ghostvv, Thanks for your response. Please have a look at my slot mappings once.

def slot_mappings(self) -> Dict[Text, Union[Dict, List[Dict]]]: “”“A dictionary to map required slots to - an extracted entity - intent: value pairs - a whole message or a list of them, where a first match will be picked”""

    return {
        "migration":[
            self.from_entity(entity="migration"),
            self.from_intent(intent="affirm", value=True),
            self.from_intent(intent="deny", value=False),
        ],
        "project_name": self.from_entity(entity="project_name", intent="inform"),
        "project_create": self.from_entity(entity="project_create", intent="inform"),
        "id": self.from_entity(entity="id",intent="inform"),
        "domain": self.from_entity(entity="domain", intent="inform"),
        "feedback": [self.from_entity(entity="feedback"), self.from_text()],
    }

what do I do with that? how do I know whether they are correct, it depends on your use case and what do you want to achieve. Please debug the nature of the problem, for example you can add additional print statements in your code to track what is happening

hi,am trying to validate start_date and end_date : code:


def validate_start_date( self, value: Text, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict[Text, Any], ) -> Dict[Text, Any]:

    if  parse(value) :
        return {"start_date": value}
    
def validate_end_date(
    self,
    value: Text,
    dispatcher: CollectingDispatcher,
    tracker: Tracker,
    domain: Dict[Text, Any],
) -> Dict[Text, Any]:
    

    if  parse(value)  and value > start_date(value):
        return {"end_date": value}

i need to set validation like " end_date should be bigger than the start_date "

issue:: i dont have an idea how to call start_date value to end_date function or wat keyword should i use to call start_date value to end_date function … can anyone help me out !!!

you can use tracker.get_slot("start_date") to extract the value in the slot start_date, please the docs for details on how to use tracker in custom action: Actions