1

I am using rasa (version 2) and with this configuration I have integrated the FallbackClassifier.

But this returns the intent name instead of any question with yes and no button. And if i press yes, then it asks the question to user

Did you mean intent_name

this is how conversation went

enter image description here

Instead of showing intent_name it should show the question. Am i missing something?

And on console

ERROR    rasa_sdk.endpoint  - No registered action found for 
name 'action_default_fallback'.
Sunil Garg
  • 14,608
  • 25
  • 132
  • 189

2 Answers2

0

In the fallback policy, rasa shows the option for most likely intent.

And by default, Rasa shows raw intent name for fallback, as we have not provided any mapping configuration. So if it finds the intent make_reserverations, it will show

Did you mean make_reserverations? 

and offer two buttons Yes and No.

To show custom or user friendly phrase, need to implement the action action_default_ask_affirmation

You have to create a class in actions.py

class ActionDefaultAskAffirmation(Action):
    """Asks for an affirmation of the intent if NLU threshold is not met."""

    def name(self):
        return "action_default_ask_affirmation"

    def __init__(self):
        self.intent_mappings = {}
        # read the mapping of 'intent and valid question' from a csv and store it in a dictionary
        with open(
            INTENT_DESCRIPTION_MAPPING_PATH, newline="", encoding="utf-8"
        ) as file:
            csv_reader = csv.reader(file)
            for row in csv_reader:
                self.intent_mappings[row[0]] = row[1]

    def run(self, dispatcher, tracker, domain):
        # from the list of intents get the second higher predicted intent
        # first will be nlu_fallback  
        predicted_intent_info = tracker.latest_message["intent_ranking"][1]
        # get the most likely intent name
        intent_name = predicted_intent_info["name"]
        # get the prompt for the intent
        intent_prompt = self.intent_mappings[intent_name]

        # Create the affirmation message and add two buttons to it.
        # Use '/<intent_name>' as payload to directly trigger '<intent_name>'
        # when the button is clicked.
        message = "Did you mean '{}'?".format(intent_prompt)

        buttons = [
            {"title": "Yes", "payload": "/{}".format(intent_name)},
            {"title": "No", "payload": "/out_of_scope"},
        ]

        dispatcher.utter_message(message, buttons=buttons)

        return []

and then need mapping csv file like this

//intent_name,User_Friendly_Phrase
bot_challenge,I am bot

and then make an entry in domain.yml under actions

Sunil Garg
  • 14,608
  • 25
  • 132
  • 189
0

The TwoStageFallback actually seems successful. I think the issue is that while you succesfully affirm the intent mood_great, your assistant doesn't know which action to run next and hence triggers action_core_fallback (configured in the RulePolicy configuration) (see more in the docs here).

Did you add action_default_fallback to your domain file? In case you did: You need to define an approppriate custom action in that case. If you don't want to override the default implementation you can remove the action_default_fallback from your domain file.

Tobias
  • 1,880
  • 11
  • 17