In a form, can you ask a follow-up question for additional results?

I’ve got a form which returns the top answer matching the user’s input. However, I’d like to ask the user if they’d like to see the other results returned, and based on the answer, either return the results or quit the form to get to the next action. Could someone explain how I would go about something like this?

Thanks in advance!

1 Like

Hello @jackie-chan,

Normally i’ll create another form for asking if the user want to continue and put it right after your main form.

The form has a requested_slot like ‘confirm_continue’, which will only be either True or False depends on the user’s intent (/affirm or /deny).

After asking for confirmation, if it’s True then do your logic in the submit function of your ‘continue form’, if you want to create some kind of loop you can just follow up to the main form (but remember to reset all the slots of the main form). With that the user will be able to continue using the function again and again until they deny the confirmation.

Not sure if it’s the good way to achieve this though, just my personal solution. Hope that helps :smiley:

1 Like

Thanks for the reply! What I would like to avoid is to have to ask the questions again to fill out the slots, so in fact, if there’s a way re-submit that form with all of the previously filled slots again or while in the new form, access the previous slot values so I can resubmit, that’d be ideal. Any thoughts on that?

Wait so you don’t want to ask the questions again, just resubmit the main form with the same old information that the user has provided before ?

Then in the ‘continue form’ just ask for the confirmation to continue, if the user agrees, you follow up to the main form without reseting any of the slots. The main form will not ask any question (since all the slots are still filled with old values) and will just jump to submit again.

“… you follow up to the main form without reseting any of the slots”

I think this is where I’m lost :slight_smile: .Could you help me with how this would be done? Fairly new to Rasa myself so anything you could point me to would be great!

Oh my bad, so basically Rasa has something called Events, you can read more about them here: Events

Anyway, in the run function of a custom action or submit function of a form action, a list of Events needs to be returned. These events can trigger the bot’s actions like: set this slot as X, restart conversations, follow up with action A,…

Normally if you don’t want to trigger any Events, you’ll return an empty list [], as you can see in the end of the submit function. If you want to tell the bot to execute a specific action right after this, you can return a FollowUp event like [FollowUp('action A')], and the bot will execute ‘action A’ after submitting the form.

So if you return an event [FollowUp('main form')] after submitting the ‘continue form’, the bot will just execute the main form again, and since all the slots are already filled, it will resubmit without asking any question. Then it goes to the ‘continue form’, keep looping until the user no longer want to continue.

P/S: Of course you have to check if the user agrees to continue, then return the followup event, if not just return the empty list.

Hope that helps :smiley:

1 Like

Awesome! Thanks so much! I’ll give this a try!