我正在编写我的第一个Alexa技能,当我试图获得认证时,它被踢了回来,因为它没有回应不正确的请求。我实现了一个未处理的功能,但它仍然给我一个“请求的技能响应存在问题。”清理器是我在Lambda的测试响应窗口中得到响应。当我在Lambda中运行测试时,我得到:
{
"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"
}
}
}
}
}
我的输出是:
{
"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"
}
}
最后,其他一切正常,我使用的Unhandled功能是:
'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);
},
非常感谢任何帮助!
答案 0 :(得分:0)
您的问题不是您的未处理功能有误,而是没有被调用。
你是否在Alexa方面包含了未处理的意图?如果是这样,您如何捕获未知值以映射到此意图?尝试执行此操作时存在已知问题(请参阅Alexa Skills Kit (ASK) and Utterances)。
在您提供的输出中,调用的意图是coffeeSummary,但coffeeName插槽的值为&#39; batman&#39;。我猜猜你的咖啡意图并不知道如何处理这个问题。至少你应该在Lambda的其他意图中添加错误捕获,这样他们就可以优雅地处理意外的值。