【发布时间】:2018-09-17 18:33:28
【问题描述】:
我对 AWS 和 Alexa 技能比较陌生。我正在构建一个简单的自定义技能,根据天气为您提供穿衣建议。
我有 2 个自定义意图:dressingTodayIntent 和 DressingTomorrowIntent。在开发人员门户的服务模拟器中,我的两个意图不起作用,虽然我得到了一个 lambda 响应,但输出语音未定义,如下所示:
{
"version": "1.0",
"response": {
"outputSpeech": {
"type": "SSML",
"ssml": "<speak> undefined </speak>"
},
"card": null,
"reprompt": null,
"speechletResponse": {
"outputSpeech": {
"id": null,
"ssml": "<speak> undefined </speak>"
},
"card": null,
"directives": null,
"reprompt": null,
"shouldEndSession": true
}
},
"sessionAttributes": {}
}
这可能是我的意图代码中的范围问题吗?
'DressingTodayIntent': function() {
var dressingAdvice;
var speechOutput = getJSON('https://api.darksky.net/forecast/9e0495a835ed823a705a9a567eee982a/48.861317,2.348764?units=si&exclude=currently,minutely,hourly,alerts,flags',
function(err, forecast) {
if (err) {
console.log('Error occurred while trying to retrieve weather data', err);
} else {
dressingAdvice = getDressingAdvice(forecast, true);
console.log("one " + dressingAdvice);
}
console.log("two " + dressingAdvice);
return dressingAdvice;
});
console.log("three " + speechOutput);
this.response.cardRenderer("Your dressing advice for today:", speechOutput);
this.response.speak(speechOutput);
this.emit(':responseReady');
},
在 AWS Lambda 中,我看到前 2 个日志的输出正确,而第三个日志的输出错误:
- 第一个日志:“一个”+dressingAdvice,如预期的那样
- 第二个日志:“两个”+dressingAdvice,如预期的那样
- 第三条日志:“三个”+未定义
感谢您的帮助!
【问题讨论】:
-
您的调用关键字有问题?它与您的自定义插槽匹配吗?
-
它确实匹配插槽是的,这不是问题。
标签: amazon-web-services aws-lambda alexa alexa-skills-kit alexa-skill