How to use deny_suggestion_intent_name in TwoStageFallbackPolicy about out_of_scope

when i use deny_suggestion_intent_name in TwoStageFallbackPolicy –config.yml

policies:
  - name: KerasPolicy
    epochs: 500
    max_history: 5
  - name: TwoStageFallbackPolicy
    nlu_threshold: 0.7
    core_threshold: 0.6
    fallback_core_action_name: "action_default_fallback"
    fallback_nlu_action_name: "action_default_fallback"
    deny_suggestion_intent_name: "out_of_scope"
  - name: MemoizationPolicy
    max_history: 5
  - name: FormPolicy

–domain.yml

intents:
- greet
- affirm
- request_weather
- deny
- goodbye
- thanks
- whoareyou
- whattodo
- out_of_scope

responses:
  utter_answer_out_of_scope:
  - text: you are out_of_scope

–nlu.md not define out_of_scope intent in nlu.md

when deny two times,activate the “action_default_fallback” only,but not out_of_scope,why?how to define “out_of_scope” in domain.yml or nlu.md or else.

I have been confused for a long time, if you have encountered similar problems, please help me, thank you, I just started to learn RASa, there are many things I do not understand

Hi @Mr.chen, welcome to the Rasa Forum!

The TwoStageFallbackPolicy uses the actions you have defined in your config. action_default_fallback is a default action in Rasa Core which sends the utter_default response to the user. Make sure to specify the utter_default in your domain file - see the docs here. You also need to specify utter_ask_rephrase, since the first stage of the TwoStageFallbackPolicy uses this - see here If you want it to run utter_answer_out_of_scope as the final action instead of action_default_fallback for NLU fallback, you need to put that in your config, like this:

policies:
  - name: KerasPolicy
    epochs: 500
    max_history: 5
  - name: TwoStageFallbackPolicy
    nlu_threshold: 0.7
    core_threshold: 0.6
    fallback_core_action_name: "action_default_fallback"
    fallback_nlu_action_name: "utter_answer_out_of_scope"
    deny_suggestion_intent_name: "out_of_scope"
  - name: MemoizationPolicy
    max_history: 5
  - name: FormPolicy

first,thank you for your reply! What really bothers me is how to use “deny_suggestion_intent_name”,for example,i define the deny_suggestion_intent_name parameter,“deny_suggestion_intent_name: “out_of_scope””,how to config the intent “out_of_scope” in domain.yml or somewhere else,What role does deny_suggestion_intent_name play ? Although the website has an explanation, But I still don’t understand well.

thank you!

Ok, I see what you’re asking. What deny_suggestion_intent_name means is that in the second stage of TwoStageFallback:

? Did you mean 'greet'?  (Use arrow keys)                
 » 1: Yes (/greet)
   2: No (/out_of_scope)
   Type out your own message...   

So when the user clicks “No”, that intent gets sent.

You add the out_of_scope intent (if that’s what your deny_suggestion_intent_name is called) to the domain intents: section. If you want to, you can also add training data for it to the NLU model, if you have known out-of-scope utterances, but this isn’t necessary for two stage fallback.

A mini-version of the domain would look like:

intents:
- greet
- bye
- handoff
- out_of_scope

responses:
  utter_greet:
  - text: Hi
  utter_bye:
  - text: bye
  utter_default:
  - text: Sorry, I don't seem to be able to help you.