How to insert responses/utterances in the middle of forms?

I am building a survey form where the answers are saved in slots question1, question2, question3, etc. I also want to use the response utter_questions2and3 in my form in order to set up both questions 2 and 3. However Rasa is ignoring this response even though I have it in my stories.yml file. I’ve tried moving the - action: utter_questions2and3 line to different places in my stories.yml file, but it doesn’t show up when I run rasa train or rasa interactive. Any help is appreciated!

data_stories.yml (721 Bytes)

domain.yml (1.5 KB)

Hi @alexyuwen, I think your best bet is to trigger the utterance using the Rasa SDK dispatcher from within a custom action’s method that is executed as part of the form, e.g. in method validate_question1 of a validation action validate_<form-name>. Basically, validate_question1 gets executed before the form prompts the user for slots question2/3, so you can take advantage of this and utter your custom message there. The other way could be to change the text of your utterance utter_ask_question2 to include the general introduction to questions 2 and 3 as well.

As you can see, it’s a bit complicated but that’s because the execution of forms is controlled by RulePolicy and it is by design hard to intercept. There is one way of rules/stories influencing what happens inside a form but that only applies to unhappy paths, so I think it isn’t applicable in your case.

Let me know if this helps or if you’ve got any further questions :slight_smile:

1 Like