Learn
Use Synonyms in Lambda Functions
Access the Resolved Value in Lambda

Entity resolution allows us to create synonyms for our slot values, so that we can receive consistent data in our code, but still allow a user to speak in the way that makes sense for them.

Why do we need consistency, you ask? Let’s say we are using the IMDB API to pull a list of movies based on genre. The API only accepts the genre of “action”, but your skill must work when the user asks for a synonym, like “battle”, “combat”, or “war”.

Remember that the resolved value is accessed with :

this.event.request.intent.slots.YOUR_SLOT_NAME.resolutions.resolutionsPerAuthority[0].values[0].value.name;

In the case of our movie skill, YOUR_SLOT_NAME would be genre, so you can access the resolved value with:

this.event.request.intent.slots.genre.resolutions.resolutionsPerAuthority[0].values[0].value.name;

Instructions

1.

On line 17 of main.js, we need to access the resolved value for the slot genre, and save it to the constant variable, genreResolvedTo.

Folder Icon

Take this course for free

Already have an account?