Whats the use of active_loop in stories and rules

Can someone help me understand difference between these 3 stories

- story: 1
  steps:
  - intent : greet
  - action : utter_greet
  - intent : ask_about_specials
  - action : utter_specials_info
  - action : restaurant_specials_form
  - action: utter_submit

- story: 2
  steps:
  - intent : greet
  - action : utter_greet
  - intent : ask_about_specials
  - action : utter_specials_info
  - action : restaurant_specials_form
  - active_loop: null
  - action: utter_submit

- story: 3
  steps:
  - intent : greet
  - action : utter_greet
  - intent : ask_about_specials
  - action : utter_specials_info
  - action : restaurant_specials_form
  - active_loop : restaurant_specials_form
  - active_loop: null
  - action: utter_submit

@pvbhanuteja See this linked video and you will be expert in active-loop and form https://youtu.be/U3an88fjFRc .Good Luck!

1 Like

The use of active_loop: null followed by action: utter_submit tell the bot that once a form is completed (aka all the required slots have been filled), it should execute utter_submit.

To start a form, I would suggest doing this:

- story: Activate form
  - intent : ask_about_specials
  - action : utter_specials_info
  - action : restaurant_specials_form
  - active_loop : restaurant_specials_form # Stay in the form while all the required slots have not been filled

And to stop it, I would suggest doing it in a separate story (or rule):

- rule: Submit form
  condition: # Condition that the loop is active, aka still in the form
  - active_loop: restaurant_specials_form
  steps:
  - action: restaurant_form
  - active_loop: null # The form has been completed
  - slot_was_set:
    - requested_slot: null # All the required slots have been filled
  - action: utter_submit

Look at Activating a Form and Dectivating a Form in the Docs. The video suggested by @nik202 is also good :slight_smile: