question

Rohan Chawhan avatar image
Rohan Chawhan asked

Why is alexa responding to the utterances I didn't code for?

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. This was expected after the Intent said above.


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 will just work fine and show the pricing "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).


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?


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

intentsskillsinteraction model
10 |3000 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

Rokas avatar image
Rokas answered

Let's start from the beginning.

Any of the intents added in your interaction model, can be invoked at any time. After launch user can say 'help', he can say 'stop' or any other utterance that is covered in your interaction model.

In your case, as I understood, you're using 'facts' skill as an example. If you would look at that skill launch intent handler, you would see that it only says random fact and finishes the session. You have to modify it, so that after launch, session would stay open. Then after launch skill will be listening for your input and you will be able to invoke your dog intent. Doing this is quite simple. You have to add a reprompt message and add a property shouldEndSession to false, like so:

    return handlerInput.responseBuilder
      .speak('bla bla bla, launch')
      .reprompt('bla bla bla, launch')
      .withShouldEndSession(false)
      .getResponse()

In this case, skill will listen for the user input after launch, before closing the session.

When you said "open the dog app and Tell me the price of XXXX." it acted as one shot invocation. It overcomes launch intent and goes straight to the intent you asked for.

When you said "open the dog bark", alexa session was closed, so she fell back to the default behaviour by just giving you a fact about barking.

I hope I covered everything you asked, if not, let me know what I missed and I'll try to explain it.

10 |3000 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.