Get uttered message by the dispatcher

When using custom actions, I would like to get the uttered message by the dispatcher that uses a template as a parameter.

For example when using: dispatcher.utter_message(template = “utter_greet”)

The bot will send a message to the Rasa server say for example it will be "how are you?"

What I would like to do is to return this uttered_message so I could save it in a variable.

Are you looking to get “utter_greet” or “how are you?”

I am trying to retrieve "how are you"

You should be able to get it by looking at the tracker, loop through the events looking for event==bot, check that the metadata.utter_action is the utterance that you want, then finally getting the text of that event.

You’ll understand a lot more if you print out the tracker and see it’s contents.

Something like:

for event in list(reversed(
        if event.get('event') == 'bot':
               text_you_want = event.get('text')

Hi @YuaNWA .

Thank you for your response. Much appreciated.

However, this is not really what I want to do. I want to retrieve the message, without dispatching it.

I think that dispatcher.utter_message(template = x) is doing something under the hood to be able to select a message from this template x. I want to mimic this behavior so I could retrieve the message without dispatching.

I wonder if this is possible.