How to get the intent not in the last message but in the previous, in a custom action

As I see there is rasa.core.trackers.DialogueStateTracker and rasa_sdk.Tracker, the first one has a method travel_back_in_time the second hasn’t. I want in a custom action to get the name of the intent not in the last message but in the previous. That’s something that can be done with travel_back_in_time but in a custom action the tracker is a rasa_sdk.Tracker. So how can I get the name of the intent not in the last message but in the previous or use travel_back_in_time in a custom action?

Hi @magda,

you are able to do the following in a custom action:

reversed_events = list(reversed(tracker.events))

This results in a list over which you can iterate to the point of interest. I recommend to take a look at the tracker’s full JSON to get an idea of the information that is stored in there

Did that help?

Kind regards
Julian

3 Likes

Yes thank you!