InvalidRule: Contradicting rules or stories found

Hi Everyone, I’m facing issues in rasa training. NLU model training completed but the core part is shows some issues

error: InvalidRule: Contradicting rules or stories found �

  • the prediction of the action ‘action_listen’ in story ‘Leave Application’ is contradicting with rule(s) ‘Activate form’ which predicted action ‘utter_leave’. Please update your stories and rules so that they don’t contradict each other. You can find more information about the usage of rules at Rules.

actions.py : from typing import Any, Text, Dict, List, Union

from rasa_sdk import Action, Tracker

from rasa_sdk.events import Restarted, SlotSet, EventType

from rasa_sdk.executor import CollectingDispatcher

class ValidateLeaveForm(Action):

def name(self) -> Text:

    return "leave_form"

def run(

    self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict

) -> List[EventType]:

    required_slots = ["br_employee_id", "start_date", "end_date", "reason"]

    for slot_name in required_slots:

        if tracker.slots.get(slot_name) is None:

            # The slot is not filled yet. Request the user to fill this slot next.

            return [SlotSet("requested_slot", slot_name)]

    # All slots are filled.

    return [SlotSet("requested_slot", None)]

class ActionSubmit(Action):

def name(self) -> Text:

    return "action_submit"

def run(

    self,

    dispatcher,

    tracker: Tracker,

    domain: "DomainDict",

) -> List[Dict[Text, Any]]:

    dispatcher.utter_message(template="utter_details_thanks",

                             Emp_id = tracker.get_slot('br_employee_id'),

                             Start_date = tracker.get_slot('start_date'),

                             End_date = tracker.get_slot('end_date'),

                             Reason = tracker.get_slot('reason'))

class action_restart(Action):

def name(self):

    return "action_restart"

def run(self, dispatcher, tracker, domain):

    return [Restarted()]

rules: version: “2.0”

rules:

  • rule: Say goodbye anytime the user says goodbye

    steps:

    • intent: goodbye

    • action: utter_goodbye

    • action: action_restart

  • rule: Activate form

    steps:

    • intent: leave application

    • action: utter_leave

    • action: leave_form

    • active_loop: leave_form

  • rule: Submit form

    condition:

    Condition that form is active.

    • active_loop: leave_form

    steps:

    Form is deactivated

    • action: leave_form

    • active_loop: null

    • slot_was_set:

      • requested_slot: null

    The actions we want to run when the form is submitted.

    • action: action_submit
  • rule: Ask the user to rephrase whenever they send a message with low NLU confidence

    steps:

    • intent: out_of_scope

    • action: utter_out_of_scope

Can you post your stories.yml please.

Hello @madhav-hekam, The above issue was resolved, actually now I revomed the form details in stories

Stories:

version: “2.0”

stories:

#- story: Leave Application

steps:

- intent: greet

- action: utter_greet

- intent: leave application

- action: utter_leave

#- action: utter_ask_br_employee_id

#- intent: br employee id

entities:

- br employee_id: “85968”

#- action: utter_show_br_employee_id

#- action: utter_ask_start_date

#- intent: start date

#- action: utter_show_start_date

#- action: utter_ask_end_date

#- action: utter_show_end_date

#- action: utter_ask_reason

#- intent: reason

#- action: utter_show_reason

- intent: goodbye

- action: utter_goodbye

- action: action_restart

  • story: happy path

    steps:

    • intent: greet

    • action: utter_greet

  • story: Attendance1

    steps:

    • intent: greet

    • action: utter_greet

    • intent: attendance

    • action: utter_attendance

    • action: utter_ask_employee_id

    • intent: employee id

    • action: utter_show_employee_id

    • action: utter_ask_clock_in

    • intent: clock_in

    • action: utter_show_clock_in

    • action: utter_ask_clock_out

    • intent: clock_out

    • action: utter_show_clock_out

    • intent: goodbye

    • action: utter_goodbye

    • action: action_restart

1 Like

Great ! :smiley: :+1:

1 Like

@ShahidCloudsys can you tell me that how to add entity in rules?

Hi @tanzar, Please add entities in your Domian.yml and follow this Docs Rules NLU Training Data