简体   繁体   中英

Amazon Alexa isn't recognizing a number slot

Lets say i have this in my schema:

 {
  "slots": [
    {
      "name": "number",
      "type": "AMAZON.NUMBER"
    }
  ],
  "intent": "PriceMyProduct"
}

And these utterances:

PriceMyProduct price of {number}
PriceMyProduct {number} price

In my lambda function I have this intent handler

'PriceMyProduct': function(){
        var itemNumber = this.event.request.slots.number.value;
         //DO STUFF
 }

The problem is that "itemNumber" never picks up the number of the product, so it is always undefined.

I have tried doing stuff like "price of 133202" or "133923 price", but the number value is never picked up. What could be the problem?

Try changing name of your slot from "number" to let say "priceValue". Something like this:

{
  "slots": [
    {
      "name": "priceValue",
      "type": "AMAZON.NUMBER"
    }
  ],
  "intent": "PriceMyProduct"
}

Then update utterances like this:

PriceMyProduct price of {priceValue}
PriceMyProduct {priceValue} price

And in lambda use the new name:

'PriceMyProduct': function(){
    var itemNumber = this.event.request.slots.priceValue.value;
     //DO STUFF
 }

Reason: number seems to be a reserved name

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM