0

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?

RC0993
  • 898
  • 1
  • 13
  • 44

2 Answers2

1

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

Jay A. Little
  • 3,239
  • 2
  • 11
  • 32
  • That is very insightful. I will be posting the .js code here in few hours (I don't have the password to the AWS account right now) But that is a well-drafted answer [+1] – RC0993 May 07 '19 at 07:28
  • Glad it was helpful, but honestly, this one question is very large. And as I broke it down, you really had 3 different problems that could have been 3 different questions. So if I were you, I wouldn't keep editing this one big question. Instead, come back with individual problems, include all the related code, and ask new questions for each problem you are having. You should receive better answers that way. Good luck. – Jay A. Little May 07 '19 at 07:42
0

You didn't post a lot of your code so it's hard to tell exactly what you meant but usually to handle incomplete events you can have an incomplete even handler like this:

const IncompleteDogsIntentHandler = {
// Occurs when the required slots are not filled
canHandle(handlerInput) {
    return handlerInput.requestEnvelope.request.type === 'IntentRequest'
        && handlerInput.requestEnvelope.request.intent.name === 'DogIntent'
        && handlerInput.requestEnvelope.request.dialogState !== 'COMPLETED'
},
async handle(handlerInput) {
    return handlerInput.responseBuilder
        .addDelegateDirective(handlerInput.requestEnvelope.request.intent)
        .getResponse();
}

you add this handler right above your actual handler usually in the index.js file of your lambda This might not fix all your issues, but it will help you handle the event when a user doesn't mention a dog.

Andrew Jouffray
  • 109
  • 2
  • 9