Nearyuk
Nearyuk

Reputation: 178

Can user set Slots and Slots synonyms by voice

i'v create a skill with intents and uterrance and slots I would like to know if the user is able to set a slots or slots synonym by voice.

My settings: Intent : OutletIntent Uterrence : Can you turn on {IOT} Slots : {IOT} : outlet

For example:

User :Can you turn on the outlet please Alexa : Outlet turned on

User: Can you add synonym of outlet Alexa: tell me the synonym User: Power Alexa: Done

User: Can you turn on the Power please Alexa: Power turned on

And then

Slots -> {IOT} : outlet => synonyms : Power

Hop it's clear, if not don't hesitate to tell me haha, Thanks by advance

Upvotes: 0

Views: 275

Answers (2)

AkshayM
AkshayM

Reputation: 1441

Yes, you can!

You need to create intents which could be like below:

Intent: AskForSynonymChange
Utterance: Can you add synonym of {ExistingSlotValue}?

Intent: TakeSynonymValue
Utterance: set it as {NewSynonymValue}

ExistingSlotValue is a custom slot of which values you can already define based on all the IOT slots values you have.

NewSynonymValue is of type AMAZON.SearchQuery

After this, you need to update interaction model based on the above responses you get in your handler functions.

You can take use of 'Alexa Skill Management API' (SMAPI).
More on that here: https://developer.amazon.com/docs/smapi/interaction-model-operations.html

You can get current interaction model: https://developer.amazon.com/docs/smapi/interaction-model-operations.html#get-interaction-model

Then update this interaction model with the modifications of adding {NewSynonymValue} to the synonyms of {ExistingSlotValue}: https://developer.amazon.com/docs/smapi/interaction-model-operations.html#update-interaction-model

After that, you need to publish your skill, yes, again with SMAPI:
https://developer.amazon.com/docs/smapi/skill-certification-operations.html#request

Let me know if this works for you.

Upvotes: 0

johndoe
johndoe

Reputation: 4387

You cannot change the interaction model of a skill as one of it's user.
As a developer you can always add new synonyms via the developer portal or via Alexa Skill Management API. But for each change you make in the interaction model requires your skill to be re-built.

Changes in interaction model is only possible in development skills (via portal or SMAPI), once your skill is published you will never be able to add a synonym. If you want to add, then its an interaction model change and you will have to get certified before you publish that new skill version (technically new/updated interaction model).


When you create a custom slot type, a key concept to understand is that this is training data for Alexa’s NLP (natural language processing). The values you provide are NOT a strict enum or array that limit what the user can say. This has two implications

1) words and phrases not in your slot values will be passed to you,

2) your code needs to perform any validation you require if what’s said is unknown

So you can expect Alexa to return slot values that are not defined in examples. Your IOT slot will return other values too. Just give a wide variety of examples slot values for IOT. Whenever your skill's backend receives a slot value just validate it and proceed.

If you want to only respond to user added synonyms, you can save the new slot value when the user adds it. Ex:

User: Can you add synonym of outlet
Alexa: tell me the synonym 
User: Power

Now when you receive this slot value as power, persist it against the list of synonyms added by the user for outlet in a database. ie, {IOT} slot.

Alexa: Done

Now when the user says:

User: Can you turn on the Power please 

Since Alexa passes other non defined slot values, you should get IOT slot value as power. Now in your backend check whether value power is already added as synonym for outlet and respond accordingly.

For a published skill any change in interaction model requires it be certified before the new version is live again.

Upvotes: 3

Related Questions