I’m not sure I understand your question but I think you want to know how to look back at tracker events to determine something like what the last bot utterance was. The tracker consists of a series of events described here. If you want a custom action to look back in the past events for something specific, like the last bot utterance, your custom action would do something like this:
for e in reversed(tracker.events):
if e.get("event") == 'bot':
utter_action = e.get('metadata', {}).get('utter_action')
logger.debug(f"utter_action: {utter_action}")
break