# Custom two\_stage fallback

**URL:** <https://forum.rasa.com/t/custom-two-stage-fallback/50982>\
**Category:** Rasa Open Source\
**Created:** [January 30, 2022, 9:19am UTC](https://forum.rasa.com/t/custom-two-stage-fallback/50982 "2022-01-30T09:19:45Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![ZahraDehghani99](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/zahradehghani99/32/17977_2.png) [@ZahraDehghani99](https://forum.rasa.com/u/ZahraDehghani99)\
**Post date:** [February 4, 2022, 4:19pm UTC](https://forum.rasa.com/t/custom-two-stage-fallback/50982/4 "2022-02-04T16:19:23Z")

</div>

I wrote a custom action for `action_two_stage_fallback` as follows and it worked as I expected.

```auto
class ActionTwoStageFallback(Action):
    def name(self) -> Text:
        return "action_two_stage_fallback"

    def run(self, dispatcher: CollectingDispatcher,
            tracker: Tracker,
            domain: DomainDict):  

        last_action = get_last_utter_action(tracker) 
        last_intent = tracker.latest_message.get("intent", {}).get("name")

        if last_intent == "nlu_fallback":
            # first time this action executed. Ask for rephrase message
            if last_action!="action_two_stage_fallback":
                dispatcher.utter_message(text="Please rephrase your message.")

                return []

            # second time this action executed. Connect to human operator    
            else:   
                dispatcher.utter_message(text="I am passing you to a human")
                # pause the tracker so that the bot stops responding to user input
                return[UserUtteranceReverted(), ConversationPaused()]

```

I found implementation for `get_last_utter_action` in this [link](http://forum.rasa.com/t/getting-last-executed-action-not-action-listen/9580/2).

---

_[View the full topic](https://forum.rasa.com/t/custom-two-stage-fallback/50982)._
