Intent from UserUttered event is not triggering the corresponding rule

I’m trying to invoke a rule from “action_nlu_fallback” through UserUttered(“some_text”,{“intent”: {“name”: “xyz”, “confidence”: 1.0}}) as return event. I am able to see in the logs, that the nlu core is able to extract the intent as expected (i.e intent: ‘xyz’). But the issue here is that, instead of invoking corresponding rule related to the parsed intent, rasa core is always predicting next action is “‘action_listen’”. so what changes do i need to do, so that it will trigger corresponding rule/story for the parsed intent ?

Logs:

[state 5] user intent: nlu_fallback | previous action name: action_listen

[state 6] user intent: ask_if_bot | previous action name: action_handle_nlu_fallback

2021-01-27 08:28:08 DEBUG rasa.core.policies.rule_policy - There is no applicable rule.

2021-01-27 08:28:08 DEBUG rasa.core.policies.ensemble - Predicted next action using policy_1_TEDPolicy.

2021-01-27 08:28:08 DEBUG rasa.core.processor - Predicted next action ‘action_listen’ with confidence 0.95.

2021-01-27 08:28:08 DEBUG rasa.core.processor - Policy prediction ended with events ‘[]’.

2021-01-27 08:28:08 DEBUG rasa.core.processor - Action ‘action_listen’ ended with events ‘[]’.

Hello @srinivasn5, welcome to the Forum!

I’m not sure I understand what you mean by

invoke a rule from “action_nlu_fallback” through UserUttered(“some_text”,{“intent”: {“name”: “xyz”, “confidence”: 1.0}}) as return event.

What does the rule look like right now? And what is the output of rasa --version?

Hello @j.mosig, Thanks for the reply.


> Rasa Version     : 2.1.1
> Rasa SDK Version : 2.1.2
> Python Version   : 3.6.9

Here is the thing what I’m trying to achieve.

  1. I’ve enabled FallbackClassifier for handling “out_of_scope” scenarios, so I’ve added following config in config.yml

    - name: FallbackClassifier
      threshold: 0.7
      ambiguity_threshold: 0.1
    
  2. Once this threshold is reached, I’ve created a custom_action_fallback_handler to handle the user input.

  3. In the above custom_action_fallback_handler, i am trying to invoke certain intent (lets say “xyz”)

  4. To invoke the intent I am using the UserUtter event with required payload

    class ActionNLUFallback(Action):
        def name(self):
            return "action_handle_nlu_fallback"
        async def run(
            self,
            dispatcher: CollectingDispatcher,
            tracker: Tracker,
            domain: Dict[Text, Any],
        ) -> List[Dict[Text, Any]]:
          # some prcoess...
          return ([UserUttered(
                    "show services",
                    {"intent": {"name": "supported_service", "confidence": 1.0}},
                    input_channel="socketio")])
    
  5. So what i can see in the rasa logs is, the rasa’s NLU server is able to detect the intent name, but it is not able to predict the action/story corresponding to that intent (i.e ‘xyz’)

LOGS:

[state 5] user intent: nlu_fallback | previous action name: action_listen

[state 6] user intent: ask_if_bot | previous action name: action_handle_nlu_fallback

2021-01-27 08:28:08 DEBUG rasa.core.policies.rule_policy - There is no applicable rule.

2021-01-27 08:28:08 DEBUG rasa.core.policies.ensemble - Predicted next action using policy_1_TEDPolicy.

2021-01-27 08:28:08 DEBUG rasa.core.processor - Predicted next action ‘action_listen’ with confidence 0.95.

2021-01-27 08:28:08 DEBUG rasa.core.processor - Policy prediction ended with events ‘’.

2021-01-27 08:28:08 DEBUG rasa.core.processor - Action ‘action_listen’ ended with events ‘’.

  1. Instead it is predicting “action_listen” is the next action for that intent (which is not true, since I’ve a rule mapped to that particular intent (i.e “xyz”)

     - rule: Show all supported services
         steps:
           - intent: supported_services
           - action: utter_service
    
  2. So how can I trigger a story/rule, which is corresponding to the intent , that was sent from UserUttered event ?

Let me know if any further info is required.

Before I think more about this: Is this a typo?

OOPS! Yes it’s a typo, I’ve corrected it now.

Cool, thanks. Yes, I think that doesn’t work. Have to think for an explanation, though. But why do you want to insert a user intent in this way? I think a better approach would be

rules:
- rule: Handle nlu fallback with supported_services
  steps:
  - intent: nlu_fallback
  - action: action_handle_nlu_fallback
  - slot_was_set:
    - fallback_intent: supported_services
  - action: utter_service

So your action_handle_nlu_fallback evaluates things and sets a slot fallback_intent. The rule then applies only if fallback_intent was set to supported_services.

Thanks. I will try this.