I'm building a booking bot using Python and Rasa. I want to add a confirmation step when user fills in all slots in my form. The requirements are:
- User may confirm the values.
- User may change the values.
- Bot must be expandable to handling other inputs and intents from the user.
I drew a flow-diagram which demonstrates more clearly the logic I want to implement: flow-diagram
I have 2 questions:
- How do you usually implement the confirmation step?
- How would you implement the logic on the picture?
I'm using Rasa v3.5.13 and Rasa SDK v3.5.1.
I already tried the following:
Confirmation within the form: I added an additional slot
confirmation
to the form, implemented extraction and validation to handle user input, but I couldn't make Rasa to call custom actions before or afterbook_foorm
is called. Inheriting fromFormAction
appeared to be impossible, because it doesn't inheritAction
frominterfaces.py
. Rules conflict withaction_listen
that is invoked right afterbook_foorm
. Making a wrapper action aroundbook_foorm
and calling it instead of the original form works only in the first time, but then active loop starts to callbook_foorm
instead of my wrapper.Confirmation after the form: passing a custom action in
active_loop
afterbook_form
is filled in seems to work, but I found out that Rasa only calls the lastFollowupAction
returned by my custom action, but I want to call multiple actions on each iteration. I also tried to create a custom action that only sets the categorical slotconfirmation_status
with values: "initialized", "confirmed", "rejected" or "fixed". The idea was that stories can handle my logic relying onconfirmation_status
, but they do it poorly or don't do it at all. Two stories were not enough even to just activateaction_extract_confirmation_status
afteractive_loop
was set tonull
, let alone handling all the logic.
So far, the second option seems to be OK if using rules instead of stories. But I need a lot of rules, and they may become a bottleneck in the further development. Coding my logic in python seems much more robust and easier to me, but I can't find a way to do this normally in Rasa.
UPD:
Tried out another approach:
- rule: Activate confirmation loop
steps:
- action: book_form
- slot_was_set:
- requested_slot: null
- active_loop: null
- action: action_extract_confirmation_status
- active_loop: action_extract_confirmation_status
wait_for_user_input: false
- rule: Ask for confirmation the first time
condition:
- active_loop: action_extract_confirmation_status
steps:
- action: action_extract_confirmation_status
- slot_was_set:
- confirmation_status: initialized
- action: utter_introduce_slots
- action: action_utter_slots
- action: utter_ask_for_confirmation
- rule: Ask for confirmation
condition:
- active_loop: action_extract_confirmation_status
steps:
- action: action_extract_confirmation_status
- slot_was_set:
- confirmation_status: fixed
- action: action_utter_slots
- action: utter_ask_for_confirmation
- rule: Ask for correction in confirmation loop
condition:
- active_loop: action_extract_confirmation_status
steps:
- action: action_extract_confirmation_status
- slot_was_set:
- confirmation_status: rejected
- action: utter_ask_for_correction
- rule: Finish confirmation
condition:
- active_loop: action_extract_confirmation_status
steps:
- action: action_extract_confirmation_status
- slot_was_set:
- confirmation_status: confirmed
- active_loop: null
- action: utter_booking_completed
And got another conflict:
- the prediction of the action 'action_utter_slots' in rule 'Ask for confirmation' is contradicting with rule(s) 'handling active loops and forms - action_extract_confirmation_status - action_listen' which predicted action 'action_listen'.
- the prediction of the action 'utter_ask_for_correction' in rule 'Ask for correction in confirmation loop' is contradicting with rule(s) 'handling active loops and forms - action_extract_confirmation_status - action_listen' which predicted action 'action_listen'.
- the prediction of the action 'utter_introduce_slots' in rule 'Ask for confirmation the first time' is contradicting with rule(s) 'handling active loops and forms - action_extract_confirmation_status - action_listen' which predicted action 'action_listen'.
Please update your stories and rules so that they don't contradict each other.
This is so annoying.