Mohamed hassan kadri
Mohamed hassan kadri

Reputation: 1069

Customizing the Fallback Policy message

I want to customize the default fall back message that rasa return

Did you mean Yes or no

but i couldnt find a good example or how i can ovveride is from the rasa sdk

Upvotes: 0

Views: 791

Answers (1)

Tobias
Tobias

Reputation: 1910

You have to create a custom action action_default_fallback which overwrites it. This action could look like the following:

from typing import Any, Text, Dict, List

from rasa_core_sdk import Action, Tracker
from rasa_core_sdk.executor import CollectingDispatcher
from rasa_core_sdk.events import UserUtteranceReverted


class ActionFallback(Action):

    def name(self) -> Text:
        return "action_default_fallback"

    def run(self, dispatcher: CollectingDispatcher,
            tracker: Tracker,
            domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:

        dispatcher.utter_message("Did you mean Yes or no")

        return [UserUtteranceReverted()]

Add the action_default_fallback to your actions in your domain file and add this to your endpoints file to connect Rasa Core and the Rasa Core SDK:

action_endpoint:
  url: "http://localhost:5055/webhook"

Then run Rasa Core with the --endpoints flag and specify the endpoints file.

Upvotes: 1

Related Questions