Search code examples
alexa-skills-kitalexa-slot

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


Solution

  • 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.