0

I am writing my first Alexa skill and when I tried to get it certified it was kicked back because it did not respond to incorrect requests. I implemented an unhandled function but it is still giving me a "there was a problem with the requested skill response." The clencher is I get the response back in the testing response window from Lambda. When I run the test in Lambda I get :

{
  "errorMessage": "Cannot read property 'summary' of undefined",
  "errorType": "TypeError",
  "stackTrace": [
    "Object.coffeeSummary (/var/task/index.js:125:96)",
    "emitNone (events.js:86:13)",
    "AlexaRequestEmitter.emit (events.js:185: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)",
    "exports.handler (/var/task/index.js:154:9)"
  ]
}

Request ID:
"4bbfad00-6f80-11e8-a9da-1b6bd5a197ec"

Function Logs:
START RequestId: 4bbfad00-6f80-11e8-a9da-1b6bd5a197ec Version: $LATEST
2018-06-14T03:09:05.263Z    4bbfad00-6f80-11e8-a9da-1b6bd5a197ec    Warning: Application ID is not set
2018-06-14T03:09:05.263Z    4bbfad00-6f80-11e8-a9da-1b6bd5a197ec    Unexpected exception 'TypeError: Cannot read property 'summary' of undefined':
TypeError: Cannot read property 'summary' of undefined
    at Object.coffeeSummary (/var/task/index.js:125:96)
    at emitNone (events.js:86:13)
    at AlexaRequestEmitter.emit (events.js:185:7)
    at AlexaRequestEmitter.EmitEvent (/var/task/node_modules/alexa-sdk/lib/alexa.js:216:10)
    at AlexaRequestEmitter.ValidateRequest (/var/task/node_modules/alexa-sdk/lib/alexa.js:181:23)
    at AlexaRequestEmitter.HandleLambdaEvent (/var/task/node_modules/alexa-sdk/lib/alexa.js:126:25)
    at AlexaRequestEmitter.value (/var/task/node_modules/alexa-sdk/lib/alexa.js:100:31)
    at exports.handler (/var/task/index.js:154:9)
2018-06-14T03:09:05.263Z    4bbfad00-6f80-11e8-a9da-1b6bd5a197ec    {"errorMessage":"Cannot read property 'summary' of undefined","errorType":"TypeError","stackTrace":["Object.coffeeSummary (/var/task/index.js:125:96)","emitNone (events.js:86:13)","AlexaRequestEmitter.emit (events.js:185: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)","exports.handler (/var/task/index.js:154:9)"]}
END RequestId: 4bbfad00-6f80-11e8-a9da-1b6bd5a197ec
REPORT RequestId: 4bbfad00-6f80-11e8-a9da-1b6bd5a197ec  Duration: 10.64 ms  Billed Duration: 100 ms     Memory Size: 128 MB Max Memory Used: 35 MB  

input:
{
 "version": "1.0",
 "session": {
  "new": false,
  "sessionId": "amzn1.echo-api.session.a35f67e9-4f2c-4fb5-b0a6-884dcb11ffd4",
  "application": {
   "applicationId": "amzn1.ask.skill.06f610ba-ca2a-447a-8fe1-65d9b1f1e4a6"
  },
  "user": {
   "userId": "amzn1.ask.account.AFAEZIHODKU6ONI6DZWPPO2JNWEVSFLUKG3QOBXP3JMI6UGMLJ7OFKIO4ZYFITEUF6VBMSXP4VWQP7EWADKLSRDWYPRTHDMG4VIO64WDH35ON3BI3NCET6E5UUET6XX676NEJLMGWQ2SXD2FQVZEUOYASXVC6C7Y3HGDPGUNEEA4NEQ7IFWAPJNID2OYWY263DEAMWAPMRLHKJA"
  }
 },
 "context": {
  "AudioPlayer": {
   "playerActivity": "IDLE"
  },
  "Display": {
   "token": ""
  },
  "System": {
   "application": {
    "applicationId": "amzn1.ask.skill.06f610ba-ca2a-447a-8fe1-65d9b1f1e4a6"
   },
   "user": {
    "userId": "amzn1.ask.account.AFAEZIHODKU6ONI6DZWPPO2JNWEVSFLUKG3QOBXP3JMI6UGMLJ7OFKIO4ZYFITEUF6VBMSXP4VWQP7EWADKLSRDWYPRTHDMG4VIO64WDH35ON3BI3NCET6E5UUET6XX676NEJLMGWQ2SXD2FQVZEUOYASXVC6C7Y3HGDPGUNEEA4NEQ7IFWAPJNID2OYWY263DEAMWAPMRLHKJA"
   },
   "device": {
    "deviceId": "amzn1.ask.device.AGGQZGS47PMEBCEAW7KRDL54HECULHEIZU3NO7XOR7TVMU4JYU6YJGRSNLNONQCI4CGJSKFWHY7YEL2GY37HVZYGDLKUOCCJZYS4SOG6KRIINFCS5TW3PSIGJZA7IE47ONZQMC6HMGYFNZYT2SERP7EXYTK7LBOJCCRI3XPEE33FQZZDBF274",
    "supportedInterfaces": {
     "AudioPlayer": {},
     "Display": {
      "templateVersion": "1.0",
      "markupVersion": "1.0"
     }
    }
   },
   "apiEndpoint": "https://api.amazonalexa.com",
   "apiAccessToken": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IjEifQ.eyJhdWQiOiJodHRwczovL2FwaS5hbWF6b25hbGV4YS5jb20iLCJpc3MiOiJBbGV4YVNraWxsS2l0Iiwic3ViIjoiYW16bjEuYXNrLnNraWxsLjA2ZjYxMGJhLWNhMmEtNDQ3YS04ZmUxLTY1ZDliMWYxZTRhNiIsImV4cCI6MTUyODk0Njg5MiwiaWF0IjoxNTI4OTQzMjkyLCJuYmYiOjE1Mjg5NDMyOTIsInByaXZhdGVDbGFpbXMiOnsiY29uc2VudFRva2VuIjpudWxsLCJkZXZpY2VJZCI6ImFtem4xLmFzay5kZXZpY2UuQUdHUVpHUzQ3UE1FQkNFQVc3S1JETDU0SEVDVUxIRUlaVTNOTzdYT1I3VFZNVTRKWVU2WUpHUlNOTE5PTlFDSTRDR0pTS0ZXSFk3WUVMMkdZMzdIVlpZR0RMS1VPQ0NKWllTNFNPRzZLUklJTkZDUzVUVzNQU0lHSlpBN0lFNDdPTlpRTUM2SE1HWUZOWllUMlNFUlA3RVhZVEs3TEJPSkNDUkkzWFBFRTMzRlFaWkRCRjI3NCIsInVzZXJJZCI6ImFtem4xLmFzay5hY2NvdW50LkFGQUVaSUhPREtVNk9OSTZEWldQUE8ySk5XRVZTRkxVS0czUU9CWFAzSk1JNlVHTUxKN09GS0lPNFpZRklURVVGNlZCTVNYUDRWV1FQN0VXQURLTFNSRFdZUFJUSERNRzRWSU82NFdESDM1T04zQkkzTkNFVDZFNVVVRVQ2WFg2NzZORUpMTUdXUTJTWEQyRlFWWkVVT1lBU1hWQzZDN1kzSEdEUEdVTkVFQTRORVE3SUZXQVBKTklEMk9ZV1kyNjNERUFNV0FQTVJMSEtKQSJ9fQ.BZwvPMVdXCCkSPx069td941AaY_gHwWY9dDfn7kmMPdKCWtlze73ZrHwe2GjU4ARWj3XoNuywW9dSmMO_oKO1wsy_q-4EwqQYrr3SSRbkY27yHKwAnTn70yGhbpfeDjQnVL12KG7xkny57C5FPzxz5k8toyxVQz90SKzd4guF_5mVpTK-umTe24ow1U6QvlPMECrv5gLKrnvvP47ilf-gYGy9UQtdU4RlK5U8pLRSRMGT4rkHxDy43BuaapfrsgnlXPHKo8ez-gkFU0BZhW8cjWtNAhaDIdBlo_yJfS5lEHWC_xGwuxR_Kz1lLIMdPKidSQ5VfeTNJiXcjK2HnSW5A"
  }
 },
 "request": {
  "type": "IntentRequest",
  "requestId": "amzn1.echo-api.request.bffd0119-da81-4552-811d-93b5c5770ef2",
  "timestamp": "2018-06-14T02:28:12Z",
  "locale": "en-US",
  "intent": {
   "name": "coffeeSummary",
   "confirmationStatus": "NONE",
   "slots": {
    "coffeePairing": {
     "name": "coffeePairing",
     "confirmationStatus": "NONE"
    },
    "coffeeName": {
     "name": "coffeeName",
     "value": "batman",
     "resolutions": {
      "resolutionsPerAuthority": [
       {
        "authority": "amzn1.er-authority.echo-sdk.amzn1.ask.skill.06f610ba-ca2a-447a-8fe1-65d9b1f1e4a6.COFFEE_LIST",
        "status": {
         "code": "ER_SUCCESS_NO_MATCH"
        }
       }
      ]
     },
     "confirmationStatus": "NONE"
    }
   }
  }
 }
}

My output is:

{
 "body": {
  "version": "1.0",
  "response": {
   "outputSpeech": {
    "type": "SSML",
    "ssml": "<speak> I'm sorry I didn't understand that, say help for assistance or try another coffee </speak>"
   },
   "shouldEndSession": false
  },
  "sessionAttributes": {},
  "userAgent": "ask-nodejs/1.0.25 Node/v6.10.3"
 }
}

Lastly, everything else works, the Unhandled function I am using is:

   'Unhandled': function() {
        console.log("UNHANDLED");
        var reprompt = "I'm sorry I didn't understand that, say help for assistance or try another coffee";
        this.emit(':ask', reprompt, reprompt);
    },

Any help is greatly appreciated!

1 Answers1

0

Your issue isn't that your Unhandled function is wrong, it's just not being called.

Have you included an Unhandled intent on the Alexa side of things? If so, how are you trying to catch unknown values to map to this intent? There are known issues with trying to do this (see Alexa Skills Kit (ASK) and Utterances).

In the output you have provided, the intent being called is coffeeSummary, but the coffeeName slot has a value of 'batman'. I'm guessing your coffeeSummary intent does not know how to handle this. As a minimum you should be adding error catching in your other intents in Lambda, so they can deal with unexpected values gracefully.

K Mo
  • 2,125
  • 8
  • 16
  • Thank you for answering my question. My first thing is I am not quite sure how to add an unhandled intent. I tried adding one like I do the other intents and it doesn't seem to work. I didn't know I needed to catch unknown values until I started doing research on this so I am still trying to figure that out. – Seven Magpies Jun 19 '18 at 13:38
  • @Orycle As stated in my answer, there are known issues with trying to implement an unhandled intent. What usually ends up happening is that a gibberish value will be mapped to one of your valid intents regardless of the presence of an unhandled intent. You are better off, designing all of your intents to handle bad input, missing/empty slots, etc. – K Mo Jun 19 '18 at 13:58
  • Thank you for getting back to me, I will continue to try and implement error handling in my lambda intent. – Seven Magpies Jun 20 '18 at 02:54