Hello all. I’m currently in the process of migrating my existing rasa bots from 1.x to 2.x, so I’m only now getting some hands-on experience with rules.
There are a couple of concepts that I’m not quite following -
In config.yml, is RulesPolicy comprehensive enough to replace FormPolicy entirely?
Why I ask is because a rule seems to map only an intent to a response (which is helpful in some use cases), but the way I was using forms in 1.x cannot be seen as being triggered from any one intent.
For example, I have my bot driving the conversation and I try to have the user answer with as little effort as possible. Let’s say, that the business logic here is to have the bot collect the user’s information (name, email address) as soon as the path indicates that the user wants to schedule an appointment. Now, this can be inferred in a couple of ways - the user explicitly states that she wants to schedule an appointment. This utterance then gets classified under the schedule_appointment intent and it’s straightforward to define a rule for this scenario. However, another way this can happen, is that the bot asks if they user would like to schedule an appointment and the user simply responds with a “yes” (affirm intent).
I used forms in my stories for both paths in 1.x, but I can only see rules replacing forms in the former path. I’m obviously hesitant to add a rule for an “affirm” intent. What do I do here?
Since I (assuming) still need to include forms in my stories, does that still make it safe for me to remove FormPolicy from my policies? Would forms be deprecated in 3.0 or just FormPolicy?
Forms using the rule policy are meant to completely replace FormPolicy.
I agree that it wouldn’t make sense to have a rule to activate your scheduling form when a user responds with your affirm intent only. But, I’m assuming you have a story/rule of prompting that in the first place? In my mind this is another entry point for your schedule form. So, you’ll have your standard start and submit rules for this form:
rules:
- rule: Activate appointment form
steps:
- intent: schedule_appointment
- action: appointment_form
- active_loop: appointment_form
- rule: Submit appointment_form
condition:
# Condition that form is active.
- active_loop: appointment_form
steps:
- action: appointment_form
- active_loop: null
- action: utter_submit
Then, you’ll have a rule or story that prompts your question on if they’d like to schedule an appointment. You’ll need two to cover the affirm + deny scenarios:
- rule: offering appointment, affirm
steps:
# you have the user doing something, then offer the appointment:
- action: utter_appointment_request
- intent: affirm
- action: appointment_form
- active_loop: appointment_form
- rule: offering appointment, deny
steps:
# you have the user doing something, then offer the appointment:
- action: utter_appointment_request
- intent: deny
- action: utter_appointment_deny
But, I’m assuming you have a story/rule of prompting that in the first place?
Yes I had a story for both the affirm and deny use cases, and through the migration script for 1.x to 2.x, it got replaced with an active_loop line in my stories. No new rule was created (which was expected). Initially, I was a little confused that to complete the migration for my forms, I needed to also create a rule, driven by the user’s intent.
Also, if I had a story for the form to run, then do I also need the affirm/deny rules that you have listed there?
Ah ok, I’ll look into the reason why an initiate form wasn’t created in migration… do you have your 1.x data posted anywhere that I could debug this?
Also, if I had a story for the form to run, then do I also need the affirm/deny rules that you have listed there?
Yes! These can be stories or rules, but generally we use rules to make sure it triggers. You would need both since you have different actions that happen depending on affirm/deny. If this was collecting a slot and the answer after didn’t change, you would only need one submit form rule/story.