Custom two_stage fallback

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

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.