Introduction to Forms
In this segment we will teach you how to configure Rasa Forms. Having a form has many benefits, but the main one is that it allows us to add constraints to how we collect slot values.
There are some important changes that we've made to our
entities:- shirt_sizeslots:shirt_size:type: textinfluence_conversation: truemappings:- type: from_entityentity: shirt_sizeconditions:- active_loop: shirt_size_formforms:shirt_size_form:required_slots:- shirt_size
The main thing we've added now is the
conditions in the slot mappings. This ensures
that we only store the slot information if the user is in an active form.
In order to make the form work, we need to add some rules to our
rules:- rule: Activate formsteps:- intent: ask_me_anything- action: shirt_size_form- active_loop: shirt_size_form- rule: Submit formcondition:- active_loop: shirt_size_formsteps:- action: shirt_size_form- active_loop: null- slot_was_set:- requested_slot: null- action: utter_remember
Again, we also ensure that we have stories available. Here's an example
that's been extracted from a long
rasa interactive conversation.
- story: interactive storysteps:- intent: greet- action: utter_greet- intent: mood_unhappy- action: utter_cheer_up- action: utter_did_that_help- intent: affirm- action: utter_happy- intent: repeat_shirt_size- action: action_say_shirt_size- intent: ask_me_anything- action: shirt_size_form- active_loop: shirt_size_form- slot_was_set:- requested_slot: shirt_size- slot_was_set:- shirt_size: large- slot_was_set:- requested_slot: null- active_loop: null- action: utter_remember- intent: repeat_shirt_size- action: action_say_shirt_size- intent: mood_unhappy- action: utter_cheer_up- action: utter_did_that_help- intent: affirm- action: utter_happy
Try to answer the following questions to test your knowledge.
- Why do we prefer to use conditions in our forms?
- Can you think of a situation where you don't want to use conditions?
- What will happen if the form cannot fill in a slot value?