I had the same problem today and this is how I solved it:
My use-case is for when users provide an answer that needs to be of a certain length.
Pre step: Handle your
utter_ask_<slot_name> in the action server instead. In other words, convert it into an
action_ask_<slot_name>. Let’s call it
action_ask_answer for this example.
My validate function goes as normal. If the response is less than 5 words long, it fills the slot with “None”. This also dispatchers an utterance, let’s call it
Step #1 prompts rasa to activate
action_ask_answer again, so the action server receives a request to run it.
action_ask_answer, I extract the second to latest event to see if
utter_too_short ever happened using a try/except block:
template = tracker.events[-2]["metadata"]["template_name"]
template = None
I only repeat the message when
template is not
if template != "utter_too_short":
This also works great when you are validating for other things that may require the repeated message. For example, when my users answer in a non-English language, I want to be able to say
utter_not_english followed by