Implenmenting custom two stage fallback

Hello everyone,

I checked the forum and read the documentation, but the following question still puzzles me:

I want to implement custom answers for the two stage fallback. As I unterstand, to do so it requires the following: Write a rule for the nlu_fallback which triggers the action_two_stage_fallback

Implement custom versions of utter_default and utter_ask_rephrase as these will be be the appropriate Rasa class ActionDefaultAskAffirmation

At last it is necessary to create a custom version of the class ActionDefaultAskAffirmation which is commented in the source code:

Default implementation which asks the user to affirm his intent. It is suggested to overwrite this default action with a custom action to have more meaningful prompts for the affirmations. E.g. have a description of the intent instead of its identifier name.

But how do I overwrite this class? It is possible to overwrite classes or part of them, for example: import MyClass def my_new_function(): … MyClass.old_function = my_new_function

But how do I put this to use within Rasa? Or is the solution to create a custom action and just give it the appropriate name by implementing the function:

def name(self) -> Text:
    return ACTION_DEFAULT_ASK_AFFIRMATION_NAME

Will rasa then preferably use this new function, when its run on an action server.

So what is the best way to get a custom version of the “ask affirmation” function?

I appreciate every help

Thanks everybody!

1 Like

Yes, you have to create an action with the name property set to “action_default_ask_affirmation” You also have to add action_default_ask_affirmation to your domain file and retrain it. Then update your config.yml and rules.yml as stated in the docs.

In addition to @user0042 's reply, here’s the documentation that can be helpful to write custom actions. And you can find instruction to run the custom action server here: Running a Rasa SDK Action Server