我正在使用自定义Lambda函数来处理我的自定义Alexa技能。我有一个要捕获的插槽。不幸的是,意图槽从来没有填充任何值,尽管已在请求中,但似乎被忽略了。
这是我的代码(注意:JSON.stringify
可以帮助我调试):
'use strict';
var Alexa = require("alexa-sdk");
exports.handler = function(event, context, callback) {
var alexa = Alexa.handler(event, context);
alexa.registerHandlers(handlers);
alexa.execute();
};
var handlers = {
'LaunchRequest': function () {
this.emit('Snow');
},
'Snow': function () {
var place = this.event.request.intent.slots.Place;
var text = 'Over the next 9 days you can expect 12 centimeters of snowfall in '+ JSON.stringify(place) +'. The upper piste has a depth of 75 centimeters and the lower piste has a depth of 35 centimeters. All 19 lifts are currently open.';
this.emit(':tell', text);
}
};
我有一个名为“ Snow”的Intent和一个名为“ Place”的插槽。这是我的互动模型:
{
"interactionModel": {
"languageModel": {
"invocationName": "ski club",
"intents": [
{
"name": "AMAZON.FallbackIntent",
"samples": []
},
{
"name": "AMAZON.CancelIntent",
"samples": []
},
{
"name": "AMAZON.HelpIntent",
"samples": []
},
{
"name": "AMAZON.StopIntent",
"samples": []
},
{
"name": "AMAZON.NavigateHomeIntent",
"samples": []
},
{
"name": "Snow",
"slots": [
{
"name": "Place",
"type": "AMAZON.City"
}
],
"samples": [
"how the powder is",
"what the powder is like",
"how the snow is",
"what the snow is like",
"snow conditions",
"snow condition",
"snow fall",
"snowfall",
"powder levels",
"powder level",
"snow level",
"powder depth",
"snow levels",
"snow depth",
"powder",
"snow",
"the snow"
]
}
],
"types": []
},
"dialog": {
"intents": [
{
"name": "Snow",
"confirmationRequired": false,
"prompts": {},
"slots": [
{
"name": "Place",
"type": "AMAZON.City",
"confirmationRequired": false,
"elicitationRequired": true,
"prompts": {
"elicitation": "Elicit.Slot.115004419453.153941565683"
}
}
]
}
]
},
"prompts": [
{
"id": "Elicit.Slot.115004419453.153941565683",
"variations": [
{
"type": "PlainText",
"value": "Where would you like to know about the snow?"
}
]
}
]
}
}
我希望能够问到:
Alexa ask my app how the snow is in Morzine
我希望能从我的Lambda函数获得包含静态文本的答案,包括插入的名称。但是,我得到以下信息:
{
"body": {
"version": "1.0",
"response": {
"outputSpeech": {
"type": "SSML",
"ssml": "<speak> Over the next 9 days you can expect 12 centimeters of snowfall in {\"name\":\"Place\",\"confirmationStatus\":\"NONE\"}. The upper piste has a depth of 75 centimeters and the lower piste has a depth of 35 centimeters. All 19 lists are currently open. </speak>"
},
"shouldEndSession": true
},
"sessionAttributes": {},
"userAgent": "ask-nodejs/1.0.25 Node/v8.10.0"
}
}
似乎Place
从来没有value
。
如果完全省略Place插槽,我会得到完全相同的响应:
Alexa ask my app how the snow is
我希望在这里给我一个空位。
这是Alexa的JSON输入(我已经编辑了一些键):
{
"version": "1.0",
"session": {
"new": true,
"sessionId": "amzn1.echo-api.session.***",
"application": {
"applicationId": "amzn1.ask.skill.***"
},
"user": {
"userId": "amzn1.ask.account.***"
}
},
"context": {
"System": {
"application": {
"applicationId": "amzn1.ask.skill.***"
},
"user": {
"userId": "amzn1.ask.account.***"
},
"device": {
"deviceId": "amzn1.ask.device.***",
"supportedInterfaces": {}
},
"apiEndpoint": "https://api.eu.amazonalexa.com",
"apiAccessToken": "***.***.***
},
"Viewport": {
"experiences": [
{
"arcMinuteWidth": 246,
"arcMinuteHeight": 144,
"canRotate": false,
"canResize": false
}
],
"shape": "RECTANGLE",
"pixelWidth": 1024,
"pixelHeight": 600,
"dpi": 160,
"currentPixelWidth": 1024,
"currentPixelHeight": 600,
"touch": [
"SINGLE"
]
}
},
"request": {
"type": "IntentRequest",
"requestId": "amzn1.echo-api.request.92fc43d8-0dc2-4a08-a31a-70a031e2fef7",
"timestamp": "2018-11-16T16:51:17Z",
"locale": "en-GB",
"intent": {
"name": "Snow",
"confirmationStatus": "NONE",
"slots": {
"Place": {
"name": "Place",
"confirmationStatus": "NONE"
}
}
},
"dialogState": "STARTED"
}
}
答案 0 :(得分:0)
我的意图需要包括广告位本身,而不像我想的那样假定它在其中。这是通过附加{Place}
来完成的。