我目前正在使用我自己的 .NET-Backend 构建一个 Alexa Skill,它应该从我的服务返回一个包含动态内容的 AlexaTextList。Alexa 的请求如下所示:
{
"version": "1.0",
"session": {
"new": false,
"sessionId": "amzn1.echo-api.session.d5f8d9ee-bdd0-4c70-96g9-b468b6b76cd4",
"application": {
"applicationId": "amzn1.ask.skill.a07cbc1c-b942-47d6-8fa2-84ebb61f1b15"
},
"user": {
"userId": "amzn1.ask.account.AE5FYATFIAFQF4UKWWBLICFMLP4ZV6KSNQFZJSECBBMKQFEL2UNUD46CDHO67QQPUQ4JZAG53CMBYUWVOWNVXMHRBBUT7ATRZDX6KRV4U2QU5FSHGL6JGOAHWRPS77PSB2N2MLFP2WKCCSC6SPZXVQKY45DLAXOD2OOFQLVGIZ6PCBRWZAEAKZKSMPWI4D36EUGPJDMVURI6BWY"
}
},
"context": {
"Viewports": [
{
"type": "APL",
"id": "main",
"shape": "RECTANGLE",
"dpi": 160,
"presentationType": "STANDARD",
"canRotate": false,
"configuration": {
"current": {
"mode": "HUB",
"video": {
"codecs": [
"H_264_42",
"H_264_41"
]
},
"size": {
"type": "DISCRETE",
"pixelWidth": 1024,
"pixelHeight": 600
}
}
}
}
],
"Viewport": {
"experiences": [
{
"arcMinuteWidth": 246,
"arcMinuteHeight": 144,
"canRotate": false,
"canResize": false
}
],
"mode": "HUB",
"shape": "RECTANGLE",
"pixelWidth": 1024,
"pixelHeight": 600,
"dpi": 160,
"currentPixelWidth": 1024,
"currentPixelHeight": 600,
"touch": [
"SINGLE"
],
"video": {
"codecs": [
"H_264_42",
"H_264_41"
]
}
},
"Extensions": {
"available": {
"aplext:backstack:10": {}
}
},
"System": {
"application": {
"applicationId": "amzn1.ask.skill.a07cbd1c-b982-47d6-8aa1-84eeb61f1b15"
},
"user": {
"userId": "amzn1.ask.account.AE5FYATFIAFQF4UKWWBLICFMLP4ZV6KSNQFZJSECBBMKQFEL2UNUD46CDHO67QQPUQ4JZAG53CMBYUWVOWNVXMHRBBUT7ATRZDX6KRD4U2QU5FSHHL6JGOAHWRPS77QSB4N2MFFP2WKCCSC6SPZXVQKY45DLAXOD2OOFQLVGIZ6PCBRWZAEAKZKSMPWI4D36EUGPJDMVURI6BWY"
},
"device": {
"deviceId": "amzn1.ask.device.AF7IR4TWRMUA5FWIUWMXJ7726QZIXXJJ4CF62N7S3N6Q5O3RTRGORGUCJ2IFWMKO2SYDWWCO4NH2AOGR35QTQSUVVJWJSU54YACLQJW2URDL6NIQMGTN7DGI7LX76B6Y4L45FMWMGBOCVC7JCFJOWQ4WTVYDYENBZUVMJQDZ4VU23MCWAC25Y",
"supportedInterfaces": {}
},
"apiEndpoint": "https://api.eu.amazonalexa.com",
"apiAccessToken": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IjEifQ.eyJhdWQiOiJodHRwczovL2FwaS5hbWF6b25hbGV4YS5jb20iLCJpc3MiOiJBbGV4YVNraWxsS2l0Iiwic3ViIjoiYW16bjEuYXNrLnNraWxsLmEwN2NiYzFjLWI5ODItNDdkNi04ZmExLTg0ZWViNjFmMWIxNSIsImV4cCI5MTYxMjM1MTY5MywiaWF0IjoxNjEyMzUxMzkzLCJuYmYiOjE2MTIzNTEzOTMsInByaXZhdGVDbGFpbXMiOnsiY29udGV4dCI6IkFBQUGBQUFBQVFESjl5V3BUNVYwd05XZnNmQk43YzdiS2dFQUFBQUFBQUM4WXQ3ZWNBNU4vUllSdmE1UENyM1dEUlJRQUljOWhodasd3E2Y29qckk3L01zVmFCTjl1aDRhOWd4Zmw4bFF5WEc3QU9MZTlGdjhoWjNBMUhyclpYeDBkM3A1Q2w4U3pyQ0dXQU1rSWI3eVlHL1B0dDYvT05qYW1XTnBTbERMa3FZbG5WdFdzVkdQRC9LTWVqTko5TFZ4dGJ0WTZWLzVlOEhmSkp4UE9YeXB5Q3BaRWluYdRQZ2dlclN0NjlRczZoN1Y3cmtTOTE0MDE4S05HTGlaZGtXTHVPZzdSczluNUFNcTlTV1paK3lBVjhpTE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qCLpyuDWR0QhJHzS0n5H0opoyNUAF3w4nibxPxV9jmo4jdM8Fqgz3I1rvKPa2nTsrGPJfLDFxPsxtNuUGwxbWglJu4nkzg--f2cTgZE5vmKsaJoUzt5IB3c9H07IPhwC82Iw"
}
},
"request": {
"type": "IntentRequest",
"requestId": "amzn1.echo-api.request.ff4e8edd-f343-4842-82bb-79eb1c1f5c22",
"locale": "en-GB",
"timestamp": "2021-02-03T11:23:13Z",
"intent": {
"name": "RESOLVE_CONFLICT",
"confirmationStatus": "NONE",
"slots": {
}
},
"dialogState": "COMPLETED"
}
}
然后我的服务响应:
{
"version": "1.0",
"response": {
"outputSpeech": {
"type": "PlainText",
"text": "Please select a cat."
},
"directives": [
{
"type": "Alexa.Presentation.APL.RenderDocument",
"token": "resolve_action",
"document": {
"type": "APL",
"version": "1.4",
"theme": "dark",
"import": [
{
"name": "alexa-layouts",
"version": "1.2.0"
}
],
"resources": [],
"onMount": [],
"mainTemplate": {
"parameters": [
"payload"
],
"items": [
{
"type": "AlexaTextList",
"id": "peopleList",
"headerTitle": "${payload.textListData.title}",
"headerBackButton": false,
"headerAttributionImage": "${payload.textListData.logoUrl}",
"backgroundBlur": false,
"backgroundColorOverlay": true,
"listItems": "${payload.textListData.listItems}"
}
]
}
},
"datasources": {
"textListData": {
"type": "object",
"objectId": "textList",
"title": "Meeting Assistant | Resolve Conflict",
"listItems": [
{
"primaryText": "Mr. Cat",
"imageAlignment": "center",
"imageBlurredBackground": true,
"imageScale": "best-fit",
"imageThumbnailSource": "https://ichef.bbci.co.uk/news/976/cpsprodpb/12A9B/production/_111434467_gettyimages-1143489763.jpg",
"primaryAction": [
{
"type": "SetValue",
"componentId": "peopleList",
"property": "headerTitle",
"value": "Click"
}
]
}
],
"logoUrl": "https://w3-mediapool.hm.edu/mediapool/media/fk10/fk10_lokal/02_aktuelles/02_news/wintersemester_2020/langmann_3/FirstSpirit_1606121272258Akoa-logo-gradient-AKOA_Sunrise_35cm.png"
}
}
}
],
"shouldEndSession": false
}
}
我没有在 Alexa 控制台的测试环境中看到漂亮的可视化,而是检索以下内容:
"error": {
"type": "INVALID_RESPONSE",
"message": "An exception occurred while dispatching the request to the skill."
}
由于这种情况很难调试(如果您对此问题也有任何建议,请告诉我),我花了很长时间才走到这一步,但我无法解决这个问题。该错误消息非常通用,它只是无法正确解析它。但根据文档,它应该没问题(https://developer.amazon.com/en-US/docs/alexa/alexa-presentation-language/apl-interface.html#renderdocument-directive)。
有趣的是,只有在我使用响应模型中的指令字段时才会发生这种情况。基本的卡片响应工作正常,所以我认为问题一定在指令中的某个地方......你有任何想法如何继续这个吗?还是我错过了什么?
非常感谢您!