Tracking the latest utter/action of chatbot

Hi,

As described in https://rasa.com/docs/action-server/sdk-tracker, we can use Tracker to recall the latest user’s intent/entity/message, but what about getting the bot’s latest utter/action? Please take a look at this story.

- story: Cognitive Behavioral Therapy (dealing with blaming)
  steps:
  - intent: feel_sad_due_to_someone
  - action: utter_empathy
  - action: ask_scale_sadness
  - intent: scale_sadness
  - action: ask_why_sad_due_to_someone
  - intent: nlu_fallback
  - action: action_dealwith_wildcard_fallback
  - action: utter_medidation_for_being_independent

“action_dealwith_wildcard_fallback” should result in “utter_rephrase” or “utter_emotion_is_from_you” depending on the latest action.

As you can see, I will use “nlu_fallback” as a wildcard intent, and it is really important for “action_dealwith_wildcard_fallback” to get “ask_why_sad_due_to_someone” to respond properly. Please let me know if there is a way for this. Thanks!

Hello!

You could set a slot when action_dealwith_wildcard_fallback is executed. In action_dealwith_wildcard_fallback, you can check if that slot is set and do your thing. Don’t forget to unset the slot after that.

Or, take a look at tracker.events_after_latest_restart.

Setting a slot when action_dealwith_wildcard_fallback is executed cannot give any clue for whether the bot has to say utter_rephrase or utter_emotion_is_from_you. If we can set a slot for ask_why_sad_due_to_someone, it sounds plausible. Can we set a special slot for the bot’s response as well? I guess it is for NLU only.

Seems the solution from Getting last executed action(not action_listen) can be an answer. Thank you all!

I probably misunderstood what you want to check exactly, but the general idea is still the same :slight_smile:

Glad you solved it anyway!

If I’m correct, the proposed solution there, using tracker.events, is in essence the same as the one I proposed using tracker.events_after_latest_restart.

1 Like