Search code examples
javascriptamazon-web-servicesalexa-skills-kit

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?


Solution

  • 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