I want to utter an output message depending on the last form slot that is filled, and then continue filling the form slots once the message is uttered to the user.
I tried using dispatcher.utter_message() but the message only pops up once all the form slots are filled.
Is there a solution to this?
Thanks for raising this issue, @federicotdn will get back to you about it soon.
Hi @sonakshisaxena1 ,
Are you using dispatcher.utter_message() in run? If so, it'll only appear once all form slots are filled. This is not a bug.
If you want the message to appear as slots get filled, you can do that by putting dispatcher.utter_message() inside the validate_{slot} method.
e.g>
If you have a slot of type user then you can do it like:
def validate_user(self,
value: Text,
dispatcher: CollectingDispatcher,
Tracker,
Dict[Text,
) -> Optional[Text]:
if value not in predefined_user_types:
dispatcher.utter_message("Please select a valid user type.")
return {"user": None}
else:
# custom message goes here
dispatcher.utter_message("User is of correct type.")
return {"user": value}
Hope that helps. :smile:
P.S: You can read more about using forms here: https://blog.rasa.com/building-contextual-assistants-with-rasa-formaction/
Hey @sonakshisaxena1, did @lahsuk's answer help you solve your problem?
Yes @federicotdn.
Thankyou @lahsuk :)
Hello,
For me it's not working! On the last validation, the message only appear after the submit method is finished.
Can you please help me.
Thank you
Most helpful comment
Hi @sonakshisaxena1 ,
Are you using
dispatcher.utter_message()inrun? If so, it'll only appear once all form slots are filled. This is not a bug.If you want the message to appear as slots get filled, you can do that by putting
dispatcher.utter_message()inside thevalidate_{slot}method.e.g>
If you have a slot of type user then you can do it like:
Hope that helps. :smile:
P.S: You can read more about using forms here: https://blog.rasa.com/building-contextual-assistants-with-rasa-formaction/