Rasa: Uttering a message while Form Filling

Created on 23 Jul 2019  路  5Comments  路  Source: RasaHQ/rasa

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?

type

Most helpful comment

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/

All 5 comments

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

Was this page helpful?
0 / 5 - 0 ratings