Writing stories for rules which has forms with intents...unfortunately rules are contradicting with stories why?

Dear Team,

Is it possible to write stories for the rules which has forms. Thanks

Best Regards, Ravi

Can you paste the rule. and story same part?

Hi @Dustyposa

Thanks for your response. And here is my code…

rules.yml

rules:
  - rule: activate document search form
    steps:
      - intent: lookingfordocuments   # intent that triggers form activation
      - action: document_form      # run the form
      - active_loop: document_form # this form is active

  - rule: submit form
    condition:
    - active_loop: document_form   # this form must be active
    steps:
      - action: document_form      # run the form
      - active_loop: null          # the form is no longer active because it has been filled
      - slot_was_set:
        - requested_slot: null     # All the required slots have been filled
      - action: action_submit
      - action: action_reset_all_slots
      - intent: deny
      - action: utter_welcome

- rule: respond to FAQs
    steps:
    - intent: faq
    - action: utter_faq

After this i want to handle further bot questions from stories.

As of now my stories is having the below configuration…

stories.yml

version: "2.0"
stories: 
###Story for faq happy path
- story: faq happy path
  steps:
  - intent: faq
  - action: utter_ask_questions
  - intent: faq
  - action: utter_faq
  - action: utter_did_that_help
  - intent: affirm
  - action: utter_anything_else
  - intent: affirm
  - action: action_user_world

###Story for faq happy path1
- story: faq happy path
  steps:
  - intent: faq
  - action: utter_ask_questions
  - intent: faq
  - action: utter_faq
  - action: utter_did_that_help
  - intent: affirm
  - action: utter_anything_else
  - intent: deny
  - action: utter_welcome

###Story for faq sad path1
- story: faq sad path
  steps:
  - intent: faq
  - action: utter_ask_questions
  - intent: faq
  - action: utter_faq
  - action: utter_did_that_help
  - intent: deny
  - action: utter_ask_extquery
  - intent: affirm
  - action: action_user_world

###Story for faq sad path2
- story: faq sad path
  steps:
  - intent: faq
  - action: utter_ask_questions
  - intent: faq
  - action: utter_faq
  - action: utter_did_that_help
  - intent: deny
  - action: utter_ask_extquery
  - intent: deny
  - action: utter_welcome

###Story for feedbacks happy path
- story: feedbacks happy path
  steps:
  - intent: feedbacks
  - action: action_initiate_feedback_buttons

But when i add any stories for the intent “lookingfordocuments” which is configured in rules are contradicting. Thanks

I was really confused and all this is because of…

By default i am showing the user with 3-options and those options are buttons. I want render each intent on button payload.

Best Regards, Ravi

BTW, What story are you try to add in story yml?

Hi @Dustyposa

Thanks for your reply.

If you notice my stories and rules above are contradicting. How do i go with only either stories or rules in this case.

If i use only rules for FAQ, my bot isn’t responding.

If i use stories, then it isn’t working when the user try to iterate the same option twice. Thanks

Best Regards, Ravi

Hey @Dustyposa

Here is the actual issue i have created with full in details and dialogue flow.

Could you please look into and help me to fix it. Thanks in advance

Best Regards, Ravi

@krkc The rule for faq should work will, you can look this guide.

For second one, that looks the sender steps have too much. You can send /restart to clean the user steps while user complete a story.

Okay @Dustyposa you mean for this story?

Hi @Dustyposa i have been implemented the new action at every story end with “- action: action_restart” and the issue fixed. Thanks

Best Regards, Ravi

That’s great!

@krkc Can you share the complete solution, how you fixed this issue. Thanks.

Hi @nik202 Good Morning, Hope you are well and staying safe.

Here is what i did exactly.

Created an action class in my actions.py

class ActionResetAllSlots(Action):

def name(self):
    return "action_reset_all_slots"

def run(self, dispatcher, tracker, domain):
    print("resetting slots...!")
    return [AllSlotsReset()]

and removed rules from rules.yml and continued with stories… in stories.yml

stories: 
  • story: lookup documents happy path and deny for further lookup steps:

    • intent: lookingfordocuments
    • action: document_form
    • active_loop: document_form
    • active_loop: null
    • action: action_submit
    • action: action_reset_all_slots
    • action: utter_anything_else
    • intent: deny
    • action: utter_welcome
  • story: lookup documents happy path1 and affirm for further lookup steps:

    • intent: lookingfordocuments
    • action: document_form
    • active_loop: document_form
    • active_loop: null
    • action: action_submit
    • action: action_reset_all_slots
    • action: utter_anything_else
    • intent: affirm
    • action: action_user_world
    • action: action_restart

###Story for faq happy path1

  • story: faq happy path steps:
    • intent: faq
    • action: utter_ask_questions
    • intent: faq
    • action: utter_faq
    • action: utter_did_that_help
    • intent: affirm
    • action: utter_anything_else
    • intent: affirm
    • action: action_user_world
    • action: action_restart

###Story for faq happy path2

  • story: faq happy path steps:
    • intent: faq
    • action: utter_ask_questions
    • intent: faq
    • action: utter_faq
    • action: utter_did_that_help
    • intent: affirm
    • action: utter_anything_else
    • intent: deny
    • action: utter_welcome

###Story for faq sad path1

  • story: faq sad path steps:
    • intent: faq
    • action: utter_ask_questions
    • intent: faq
    • action: utter_faq
    • action: utter_did_that_help
    • intent: deny
    • action: utter_ask_extquery
    • intent: affirm
    • action: action_user_world
    • action: action_restart

###Story for faq sad path2

  • story: faq sad path steps:
    • intent: faq
    • action: utter_ask_questions
    • intent: faq
    • action: utter_faq
    • action: utter_did_that_help
    • intent: deny
    • action: utter_ask_extquery
    • intent: deny
    • action: utter_welcome

Thats it, and my problem was fixed :slight_smile:

Feel free to discuss further. Thanks

Best Regards, Ravi

@krkc No discussion required, It’s good you solved your query, I was just want the solution for others and you shared.

Hey @nik202 yes, Thank you again. Good Luck :slight_smile: