Accessing Intent_Messages


#1

Hey guys,

I’m new to snips and want to use it to track my food storage. I followed the jokestuto (https://docs.snips.ai/articles/platform/create-an-app/python-template) and managed to get this python skill up and running. Then I created my own skill and now I’m stuck with getting the intent message.

From my action-app_storage.py I access a function within a class from a second file. To test the functionality and get the intent values, I wrote a small testing function:

def testing_dummy_function(self, intent_message):
    print(intent_message)
    return "Hallo"

A normal answer from my snips skill looks like this:
{
“input”: “wieviel tomaten haben wir noch”,
“intent”: {
“intentName”: “time4breakfast:getAmountOfItem”,
“probability”: 0.90879446
},
“slots”: [
{
“rawValue”: “tomaten”,
“value”: {
“kind”: “Custom”,
“value”: “Tomaten”
},
“range”: {
“start”: 8,
“end”: 15
},
“entity”: “storage_item”,
“slotName”: “Menge”
}
]

The problem now is, that I have no clue at all on how to access or interact with the intentmessage. E.g. writing
def testing_dummy_function(self, intent_message):
item = intent_message.intent.intent_name
return “Hallo”

runs without an error. But when I try to change it to sth like:
def testing_dummy_function(self, intent_message):
item = intent_message.slots
return “Hallo”

then I get various errors concerning invalid accessing of the intent_message, e.g.
TypeError: ‘IntentClassifierResult’ object is not callable
or
AttributeError: ‘IntentClassifierResult’ object has no attribute ‘slots’

Any help is greatly appreciated.
Thanks
Liz


#2

try to_dict to convert the object to a dictionary

else try something like intentMessage.slots.{{slot_name}}.first().value


#3

Thanks for your suggestion, yet
Feb 03 10:47:00 raspberrypi snips-skill-server[1703]: INFO:snips_skill_server_lib:: runner: [app_storage][err] item = intent.slots.value.first().value
Feb 03 10:47:00 raspberrypi snips-skill-server[1703]: INFO:snips_skill_server_lib:: runner: [app_storage][err] TypeError: ‘DotMap’ object is not callable

gives me the error: ‘DotMap’ object is not callable.
But I can’t find useful information on google for that error. Any idea how to fix this?


#4

is your slot name value ??

you can convert the intent data to a dot map using to_Dict()

    slot_dict = intentMessage.slots.toDict()
    slot_array = slot_dict['my_slot_name']
    ...

#5

Ouh man! :woman_facepalming: Thank you so much!
It was the different slot name that drove me crazy. I followed another example and for one of my slots it worked totally fine and for a second one (that seemed the same) it didn’t work at all.

So, now that I accessed the slot by it’s correct name I can get all the information I want/need.

Thank you :slight_smile: