首先,如果我在alexa应用程序开发页面上使用模拟器,一切正常,尽管请求看起来有些不同。如果我对我的Alexa设备说“询问appName {x}和{y}”,则会调用我的Web服务,并显示错误消息“将请求分派给技能时发生异常”。 {X}和{Y}是我的意图插槽。
这只有在直接与Alexa交谈并且模拟器再次完美运行时才会发生。
以下是我与Amazon Echo交谈时收到的请求。
{
"version": "1.0",
"session": {
"new": false,
"sessionId": "amzn1.echo-api.session.6a13f2db-a9f6-43a9-bc4d-x063b86905b6c",
"application": {
"applicationId": "amzn1.ask.skill.ef8bd603-cc39-406e-bed8-a8f9xc94abba2"
},
"user": {
"userId": "xxx"
}
},
"context": {
"AudioPlayer": {
"playerActivity": "STOPPED"
},
"System": {
"application": {
"applicationId": "amzn1.ask.skill.ef8bd603-cc39-406e-bed8-a8f9c94abba2"
},
"user": {
"userId": "xxxx"
},
"device": {
"deviceId": "xx",
"supportedInterfaces": {
"AudioPlayer": {}
}
},
"apiEndpoint": "https://api.eu.amazonalexa.com",
"apiAccessToken": "xxxx"
}
},
"request": {
"type": "SessionEndedRequest",
"requestId": "amzn1.echo-api.request.2a993410-e7a8-4f37-87d7-a5063ef185b5",
"timestamp": "2017-12-22T00:11:45Z",
"locale": "en-GB",
"reason": "ERROR",
"error": {
"type": "INVALID_RESPONSE",
"message": "An exception occurred while dispatching the request to the skill."
}
}
}
以下是我的意图Schema
{
"intents": [
{
"intent": "StartGameIntent"
},
{
"slots": [
{
"name": "playerOne",
"type": "AMAZON.US_FIRST_NAME"
},
{
"name": "playerTwo",
"type": "AMAZON.US_FIRST_NAME"
}
],
"intent": "PlayTheGame"
},
{
"intent": "StopTheGame"
},
{
"slots": [
{
"name": "damage",
"type": "AMAZON.NUMBER"
},
{
"name": "player",
"type": "AMAZON.US_FIRST_NAME"
}
],
"intent": "PlayerTakesDamage"
},
{
"slots": [
{
"name": "health",
"type": "AMAZON.NUMBER"
},
{
"name": "player",
"type": "AMAZON.US_FIRST_NAME"
}
],
"intent": "PlayerHeals"
}
]
}
如果我问一个没有任何插槽的意图,它工作正常。为什么在有插槽时没有找到我的意图?
我正在使用Language UK运行这个应用程序。
尝试检查AWS lambda日志以查找请求的错误。它应该为您提供失败的模块名称(例如index.js)和异常的行号。
您还可以将console.log()消息添加到lambda代码中,以帮助缩小发生错误的位置。