End of form

What is the preferred method for ensuring that the conclusion of filling a form out entirely (getting to the end of it) deterministically triggers another action? I see that when my form is expended, the following are returned in my stories:

form{"name":null}
slot{"requested_slot":null}

Is there a way to ensure this triggers another action?

Thank you.

Hi @argideritzalpea!

Though it is preferred that, you mention the action which you want to call after the form, in your stories. But if you want to force some action, you can return a FollowupAction() event from the submit() method of your form. See Force a followup action for more details.

I am aware of follow up actions. I only want the followupAction to trigger at the end of the end of the form, so your suggestion wouldn’t work I don’t think.

Looks like I can overwrite the request_next_slot function.

It would be great if there were a more ‘macro’-level option for this instead of overwriting the return value of the function and adding it to the custom action server. The more hard-coded logic the user needs to create, the harder the upkeep and debugging down the road.

Yeah so like I said, you have to return the FollowupAction() event from the submit() method of your form. The submit() method is called at the very end of the form. So, it should work.

Btw, how are you planning to use the request_next_slot method?

Hey, you are right! I was thrown off by the fact that in the stories, the form is seemingly called each time a slot is filled. I thought that that would trigger the followup at the conclusion of each slot fill. Thanks for your confirmation!

@saurabh-m523 Hey, I was wondering if you happened to know how to solve the following situation:

My main goal is to allow the user to speak at the end of the form while the bot listens, but does nothing (since the form has ended). Then, after a time delay, I want the conversation session to restart.

I tried setting up this functionality with the “reminders” function, but the bot is NOT delaying in restarting the session:

relevant domain.yml:

intents:
  - goodbye
  - TIMED_RESTART: {triggers: action_session_start}
actions:
  - action_session_start
  - utter_goodbye

Relevant actions:

class ActionGoodbye(Action):
    """Resets convo"""

    def name(self):
        return "utter_goodbye"

    async def run(self, dispatcher, tracker, domain):

        date = datetime.datetime.now() + datetime.timedelta(seconds=50)

        reminder = ReminderScheduled(
            "TIMED_RESTART",
            trigger_date_time=date,
            name="restart_reminder",
            kill_on_user_message=False,
        )

class ActionSessionStart(Action):
    def name(self) -> Text:
        return "action_session_start"

    @staticmethod
    def fetch_slots(tracker: Tracker) -> List[EventType]:
        """Collect slots that contain the user's name and phone number."""

        slots = []
        for key in ("zipCode", "yearBorn"):
            value = tracker.get_slot(key)
            if value is not None:
                slots.append(SlotSet(key=key, value=value))
        return slots

    async def run(
        self,
        dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: Dict[Text, Any],
    ) -> List[EventType]:

        # the session should begin with a `session_started` event
        events = [SessionStarted()]

        # any slots that should be carried over should come after the
        # `session_started` event
        events.extend(self.fetch_slots(tracker))

        # an `action_listen` should be added at the end as a user message follows
        events.append(ActionExecuted("action_listen"))

        return events

Anyone know how to get this working in Rasa ?

Can you show the log from when you call the utter_goodbye action.