I have a simple and presumably common scenario when working with Rasa Forms. While the bot is going through the slots and asking the appropriate questions, I want to be able to respond to “please hold for one moment” intent, at which point the bot (and form) should pause and wait for the user to return, most likely resuming the conversation when the user returns and supplies the answer to the most recent question from the bot.
I created the “please hold” intent and trap it in a rule - that all works well. The trouble is my bot immediately resumes its work, reasking the most recent question (as would be expected). How can I get it to not resume asking the form questions until the user chimes back in?
I have tried some ideas (that may be from Rasa 1.x era) like creating custom action classes, e.g.
When a form is active, rules are not triggered until the form is deactivated. I was able to get an example working using your custom actions using the following story:
stories.yml
stories:
- story: User interrupts the form and wants to speak with a human agent
- intent: start_form
- action: some_form
- active_loop: some_form
- intent: human_handoff
- action: action_deactivate_loop
- active_loop: null
- action: action_chat_pause
I was also able to replicate your reported behavior in the case that the form has a from_text slot mapping. In that case, I needed to exclude the human_handoff intent in the domain.yml. Otherwise, it was extracted as a value for the slot instead of triggering the story above:
Thanks, @kearnsw! I really appreciate your help. A few things:
I have been told a few times that “rules are not triggered until the form is deactivated” on this forum and yet I have not found that to be the case. For example, in my bot, I have 7 separate forms that segment different parts of the conversation. I have a simple “please repeat the question” rule that although simple, works flawlessly across all forms:
rule: please repeat the question
steps:
intent: inform_please_repeat_question
action: utter_will_repeat_question
When the rule triggers, the bot says, “sure, I am happy to repeat the question” and then proceeds to try to fill the slot it was trying to fill when asked to repeat the question. Note that I am not including the inform_please_repeat_question intent in the not_intent section of the form slot (as others have suggested would be the only way to get around this form/rule constraint). Also, note that I am not doing this to be difficult - - but I am perplexed when something works that I am told should not work.
OK, now on to the main point of my post - again thanks for your thoughts and suggestions. I am still wondering:
once I deactivate my form loop after the human_handoff intent, how should I think about resuming it? After putting the bot on hold, the user will likely come back with an answer to the bot’s last form question (e.g. “thanks for holding…I have the information you asked for”). Is there some kind of ‘last active form’ value I can reference somewhere to restart the form?
Hmm, that’s good news about rules + forms. It seems this documentation needs to be updated. You can open an issue on Github and link to this post.
You’ll need to set the _paused property of the tracker to false. This can be achieved by appending the ConversationResumed event to the tracker. This is achieved through a POST request to http://:5005/conversations/<conversation_id>/tracker/events with the following body:
By keeping the same conversation tracker the slots should still be available and so when the form is triggered again it’ll jump to the section of the form where the user left off.