alexa-skills-kitalexa-voice-serviceavspeechutterance

Errors with multi turn dialog in alexa skills


I have created a skill with name "BuyDog" and its invocation name is "dog app"

So that should mean, I can use the intents defined inside only after the invocation name is heard. (is that correct?)

Then I have defined the Intents with slots as:

"what is {dog} price."

"Tell me the price of {dog}."

where the slot {dog} is of slot type "DogType". I have marked this slot as required to fulfill

Then I have added the endpoint to AWS lambda function where I have used the blueprint code of factskills project in node.js, and done few minor changes just to see the working.

const GET_DOG_PRICE_MESSAGE = "Here's your pricing: ";

const data = [
    'You need to pay $2000.',
    'You need to pay Rs2000.',
    'You need to pay $5000.',
    'You need to pay INR 3000.',

];
const handlers = {
//some handlers.......................
'DogIntent': function () {
        const factArr = data;
        const factIndex = Math.floor(Math.random() * factArr.length);
        const randomFact = factArr[factIndex];
        const speechOutput = GET_DOG_PRICE_MESSAGE + randomFact;
}
//some handlers.......................
};

As per the about code I was expecting when

I say: "Alexa open dog app"

It should just be ready to listen to the intent "what is {dog} price." and the other one. Instead it says a random string from the node.js code's data[] array. I was expecting this response after the Intent was spoken as the slot was required for intent to complete. Require

And when

I say: "open the dog app and Tell me the price of XXXX."

It asks for "which breed" (that is my defined question) But it just works fine and show the pricing

Alexa says: "Here's your pricing: You need to pay $5000."

(or other value from the data array) for any XXXX (i.e. dog or not dog type). Why is alexa not confirming the word is in slot set or not? slot conf

And when

I say: "open the dog bark".

I expected alexa to not understand the question but it gave me a fact about barking. WHY? How did that happen?
Does alexa have a default set of skills? like search google/amazon etc...

I am so confused. Please help me understand what is going on?


Solution

  • Without having your full code to see exactly what is happening and provide code answers, I hope just an explanation for your problems/questions will point you in the right direction.


    1. Launching Skill

    I say: "Alexa open dog app"
    It should just be ready to listen to the intent...

    You are expecting Alexa to just listen, but actually, Alexa opens your skill and is expecting you to have a generic welcome response at this point. Alexa will send a Launch Request to your Lambda. This is different from an IntentRequest and so you can determine this by checking request.type. Usually found with:

    this.event.request.type === 'LaunchRequest'
    

    I suggest you add some logging to your Lambda, and use CloudWatch to see the incoming request from Alexa:

    console.log("ALEXA REQUEST= " + event)
    

    2. Slot Value Recognition

    I say: "open the dog app and Tell me the price of XXXX."
    Why is alexa not confirming the word is in slot set or not?

    Alexa does not limit a slot to the slot values set in the slotType. The values you give the slotType are used as a guide, but other values are also accepted.

    It is up to you, in your Lambda Function, to validate those slot values to make sure they are set to a value you accept. There are many ways to do this, so just start by detecting what the slot has been filled with. Usually found with:

    this.event.request.intent.slots.{slotName}.value;
    

    If you choose to set up synonyms in the slotType, then Alexa will also provide her recommended slot value resolutions. For example you could inlcude "Rotty" as a synonym for "Rottweiler", and Alexa will fill the slot with "Rotty" but also suggest you to resolve that to "Rottweiler".

    var resolutionsArray = this.event.request.intent.slots.{slotName}.resolutions.resolutionsPerAuthority;
    

    Again, use console.log and CloudWatch to view the slot values that Alexa accepts and fills.


    3. Purposefully Fail to Launch Skill

    I say: "open the dog bark".
    I expected alexa to not understand the question but it gave me a fact about barking.

    You must be doing this outside of your Skill, where Alexa will take any inputs and try to recognize an enabled skill, or handle with her best guess of default abilities.

    Alexa does have default built-in abilities (not skills really) to answer general questions, and just be fun and friendly. You can see what she can do on her own here: Alexa - Things To Try

    So my guess is, Alexa figured you were asking something about dog barks, and so provided an answer. You can try to ask her "What is a dog bark" and see if she responds with the exact same as "open the dog bark", just to confirm these suspicions.


    To really understand developing an Alexa skill you should spend the time to get very familiar with this documentation: Alexa Request and Response JSON Formats