Is there any way to get the action name (utterance) from the API?

I’m trying to get the action name triggered by a certain intent.

I’m building a bot that doesn’t allow duplicate responses and I need the ability to get the action name.

http://localhost:5005/webhooks/rest/webhook works perfectly fine and always returns the right template… I just can’t find the utter_[name]. Trying to assume i can always do utter_#intent# doesn’t work for me, because some intents use the same utterance in a few of my stories.

I’ve tried http://localhost:5005/model/predict with no luck trying to send something like:

[ { “event”: “user”, “text”: “Hey”, “parse_data”: { “intent”: { “name”: “greet”, “confidence”: 0.9 }, “entities”: [] }, “metadata”: {}, } ]

always returns action_listen. I thought i was close with this, but can’t seem to figure it out. Any suggestions?

You can get the last intent from the tracker:

http://localhost/conversations/id/tracker where id is the sender you used in /rest/webhook. Take a look at the json returned.

In python, I use this:

import json, requests

...

TRACKER_URL = "http://localhost:5005/conversations/" + userid + "/tracker"
...

r = requests.get(TRACKER_URL)
results = json.loads(r.content.decode('utf8'))

# intent

print(results['latest_message']['intent'])

Not sure if this shows you the last action though. More info here: HTTP API

Hey. Thanks for the reply. I dont have any problem getting the actual message from the template. I need the template name (i.e. utter_greet).

Still can’t figure it out. I’m trying to make my own webhook, but seems to be the same results. Any other ideas?

This isn’t the actual message. It’s the intent name. Since it returns the whole conversation, the json can be quite large.

If you look at the json, you should find the whole conversation in the “events” array, including actions, slots being set, etc.