alexa-js / alexa-app

A framework for Alexa (Amazon Echo) apps using Node.js
https://www.youtube.com/watch?v=pzM4jv7k7Rg
MIT License
1.03k stars 213 forks source link

missing intent in request: {SLOT} TypeError: Cannot read property 'value' of undefined #191

Open tlovett1 opened 7 years ago

tlovett1 commented 7 years ago

I'm getting this error when the slot is empty:

missing intent in request: ZIPCODE TypeError: Cannot read property 'value' of undefined

My code is really simple:

app.intent('perdiem', {
    'slots': {
      'ZIPCODE': 'AMAZON.NUMBER'
    },
    'utterances': ['{|for} {|per} {diem|day} rates {|at|near|by|for} {-|ZIPCODE}']
  }, function(req, res) {
    const zipcode = req.slot('ZIPCODE', false);

    const reprompt = 'Where do you want per diem rates?';

    if (!zipcode) {
      const prompt = 'Tell me a valid zipcode.';
      res.say(prompt).reprompt(reprompt).shouldEndSession(false);
    } else {
      Government.getPerDiemRates(zipcode).then(function(rate) {
        voicead.sayWithAd('The current per diem rate is ' + rate + ' dollars', res);
      }, function() {
        debug('Error has occured.');
      });
    }

    return false;
  }
);

Why is this an error? Shouldn't it just return false to zipcode?

dblock commented 7 years ago

See if HEAD resolves this? I believe it was fixed in https://github.com/alexa-js/alexa-app/pull/184.

tlovett1 commented 7 years ago

Doesn't seem like that fixed it

shaikhzaid commented 6 years ago

It is still not fixed

dblock commented 6 years ago

Looking forward to a PR from someone with a spec + fix.

user1m commented 6 years ago

yes this is the same issue I was having in #314 . If Alexa gets an empty slot then the slot value ends up being undefined and so you get and error where you expect the defaultValue of false (in this case). Should be fixed.

akash65 commented 6 years ago

{ "errorMessage": "Cannot read property 'slots' of undefined", "errorType": "TypeError", "stackTrace": [ "Object.SayHello (/var/task/index.js:38:47)", "emitNone (events.js:106:13)", "AlexaRequestEmitter.emit (events.js:208:7)", "Object.LaunchRequest (/var/task/index.js:19:14)", "emitNone (events.js:106:13)", "AlexaRequestEmitter.emit (events.js:208:7)", "AlexaRequestEmitter.EmitEvent (/var/task/node_modules/alexa-sdk/lib/alexa.js:216:10)", "AlexaRequestEmitter.ValidateRequest (/var/task/node_modules/alexa-sdk/lib/alexa.js:181:23)", "AlexaRequestEmitter.HandleLambdaEvent (/var/task/node_modules/alexa-sdk/lib/alexa.js:126:25)", "AlexaRequestEmitter.value (/var/task/node_modules/alexa-sdk/lib/alexa.js:100:31)" ] }

I'm also getting error like can anyone help me?

akash65 commented 6 years ago

"request": { "type": "IntentRequest", "requestId": "amzn1.echo-api.request.5292afe2-03d8-4cc5-959f-54715d91322e", "timestamp": "2018-07-18T11:55:26Z", "locale": "en-US", "intent": { "name": "HelloWorldIntent", "confirmationStatus": "NONE", "slots": { "number": { "name": "number", "confirmationStatus": "NONE"

why i'm not getting value here?