u936293
u936293

Reputation: 16232

Why am I not receiving the slot?

My request is as follows:

"request": {
 "type": "IntentRequest",
 "requestId": "EdwRequestId.0941c2f8-30b3-4001-aa05-1cec3a715b05",
 "intent": {
   "name": "Buses",
   "slots": {
     "Heading": {
       "name": "Heading",
       "value": "eastbound"
     }
   }
 },
 "locale": "en-US",
 "timestamp": "2017-12-27T02:45:22Z"
}

The above was generated by the Service Simulator after I supplied the activation utterance.

My AWS Lambda function has the following:

'Buses': function() {
    const itemSlot = this.event.request.intent.slots.Item;
    let heading;
    if (itemSlot && itemSlot.value) {
        console.log(itemSlot.value);
        heading = itemSlot.value.toLowerCase();
    }
    else
        console.log("No slots!");

No slots! was output to the console.

Upvotes: 0

Views: 128

Answers (1)

Anthony Neace
Anthony Neace

Reputation: 26003

As written, your request and your code are doing what they should be. Using the service simulator request as an example, your request only defines one slot identified as "Heading":

   "slots": {
     "Heading": {
       "name": "Heading",
       "value": "eastbound"
     }

Since no slot identified as "Item" is present, your itemSlot variable is undefined and evaluates the else condition.

If you have no slot in your utterance called "Item", you may have meant to simply reference the Heading slot, like so:

this.event.request.intent.slots.Heading;

If you do have a slot called "Item" in your utterance, it is possible that the simulator identified a difference utterance without "Item" and used it instead. You can troubleshoot this by checking your utterances and the sample request to the simulator, to make sure they're routing as you expect. You may also debug to inspect this.event.request.intent.slots, to verify that you're receiving slots at all in your lambda.

Upvotes: 2

Related Questions