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
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'.
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