Hi Guys,
after like searching 4 hours on the internet and trying out several things, I gave up fixing the error by myself.
I am new to rasa and just built the “getting started” contextual assistant. After I finished it and I wanted to add some custom logic.
I wanted to add a validation function, which checks if the slot ‘job_function’ is ‘sales manager’ otherwise it should directly end the form. This is my validation function:
def get_allow_jobs() -> List[Text]:
"""Database of allowed job functions"""
return [
"sales manager",
]
def validate_job_function(
self,
value: Text,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],
) -> Dict[Text, Any]:
"""validate_job_function"""
if any(tracker.get_latest_entity_values("job_function")):
if value.lower() in self.get_allow_jobs():
# validation succeeded, set the value of the "cuisine" slot to value
return {"job_function": value}
else:
dispatcher.utter_message(f"Sorry, your job {value} is not allowed to contact sales, only sales manager allowed to contact sales. \n Please reach out to your sales manager")
# validation failed, deactivating the form
self.deactivate()
The problem is if I answer the question “what`s your job?” with lets say “engineer”. its return correctly my message from the validation but it directly start asking the question again “what´s your job”.
Can you help me? My goal is the messages gets send and the form is cancelled and the user could ask different question or say goodbye or do what ever he wants