Can the bot make an utterance and then immediately start a form?

I want my bot to say something before starting a form, but I’m having trouble. Using the formbot found in the rasa github repo under rasa/examples/formbot, I want to have a story like this:

## happy path
* greet
    - utter_greet
* request_restaurant
    - utter_greet
    - restaurant_form
    - form{"name": "restaurant_form"}
    - form{"name": null}
    - utter_slots_values
* thankyou
    - utter_noworries 

In this example, I want the bot to utter_greet again after the request_restaurant intent before the form intent. But something goes wrong in the the training because when I have a conversation and trigger /greet and then /request_restaurant, the bot responds with the utter_default message.

The bot works as expected if I remove the second -utter_greet action.

I thought that the bot could take any number of actions in a row. Why can’t I have the bot do an utter action before a form action?

Yes, you can do this by using custom action and returning a followup form in actions.

Story:

    * request_restaurant
    - action_greet

actions.py:

from rasa_sdk.events import (
SlotSet,
UserUtteranceReverted,
ConversationPaused,
EventType,
AllSlotsReset,
FollowupAction,
)

class ActionGreet(Action):
def name(self):
    return "action_greet"

def run(self, dispatcher, tracker, domain):
    
    dispatcher.utter_message(template="utter_greet")
    
    return [FollowupAction("restaurant_form")]
1 Like

Thanks.

I updated my actions.py, stories.yml and domain.yml files to include the action_greet, but it’s still responding with utter_default. I’ve tried adding some form events to the story like this:

## happy path
* greet
    - utter_greet
* request_restaurant
    - action_greet
    - form{"name": "restaurant_form"}
    - form{"name": null}
    - utter_slots_values

But this still doesn’t work

@plurn Kan you please elaborate your story

So the problem I was having was my action_greet made an utterance, but I thought that was being ignored. But this was actually a front end problem because my chatbot was only showing the most recent bot utterance if there were actually more than one.

So this actually works. Thanks for your response, though. I wasn’t aware of FollowupAction before this, and that’s pretty useful.