question

Michael McGurrin avatar image
Michael McGurrin asked ·

Python sdk: How do I get the spoken slot value?

If i want to get the canonical matching value, I use something like:

direction = (slots["direction"].value)

how do I get the actual spoken value, which may be a synonym?


Thanks!

slotspythonsdk v2
10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Brian@Amazon avatar image
Brian@Amazon answered ·

Value, as defined in your question, should be the spoken value from the skill user. If you look at the resolutions object (specifically the values subattribute) you can see that it has resolved to a canonical "name" and canonical "id" which you can set in the interaction model.

There is a great example of this here: https://developer.amazon.com/docs/custom-skills/define-synonyms-and-ids-for-slot-type-values-entity-resolution.html#er-built-in-types

In this case, the developer has said "the windy city" which appears under value, whereas the name is "Chicago" and the id is the airport code, "ORD".

3 comments
10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Thanks, my bad. But what is the syntax for reading out the canonical name and/or id in python?

1 Like 1 ·

you can get the name like this: intent.slots[slot_name].resolutions.resolutions_per_authority[0].values[0].value.name

Please see this blog for entity resolution details.

You can also refer to this sample code written in python.

1 Like 1 ·
Giovanni scheer avatar image Giovanni scheer meliogin+jp ♦♦ ·

Mellogin THANKS FOR YOU HELP

I'M in LOVE with you

0 Likes 0 ·