【发布时间】:2018-06-01 19:23:14
【问题描述】:
我已经创建了我的第一个测试 Alexa 技能,它应该做的就是让 Alexa 侮辱你。 (我知道这已经创建,但这只是一个测试) 我一直在学习教程,但是现在当我在回声上打开技能时,我得到的响应是“抱歉,出了点问题”。 被调用的代码是
this.emit(":tellWithCard", speechOutput, SKILL_NAME, randomInsult);
这是我在服务模拟器上得到的服务响应:
{
"version": "1.0",
"response": {
"outputSpeech": {
"ssml": "<speak> Nah shut up, you bad little weapon </speak>",
"type": "SSML"
},
"card": {
"content": "Nah shut up, you bad little weapon",
"title": "Insulter"
},
"speechletResponse": {
"outputSpeech": {
"ssml": "<speak> Nah shut up, you bad little weapon </speak>"
},
"card": {
"content": "Nah shut up, you bad little weapon",
"title": "Insulter"
},
"shouldEndSession": true
}
},
"sessionAttributes": {}
}
在我遵循的教程中,speechlet 响应不在服务响应中,有人知道为什么它现在包含在我的响应中吗?我不确定我的代码中是否存在错误,或者 Lambda 函数的工作方式是否发生了变化。这是 cloudwatch 上的回复:
21:12:48
START RequestId: 4085e037-b9c9-11e7-b5e8-23df701a71f2 Version: $LATEST
21:12:48
2017-10-25T21:12:48.029Z 4085e037-b9c9-11e7-b5e8-23df701a71f2
Warning: Application ID is not set
21:12:48
END RequestId: 4085e037-b9c9-11e7-b5e8-23df701a71f2
21:12:48
REPORT RequestId: 4085e037-b9c9-11e7-b5e8-23df701a71f2 Duration: 0.68
ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Us
这是我的 index.js 代码:
"use strict";
//Variables
var Alexa = require("alexa-sdk");
var SKILL_NAME = "Insulter";
var APP_ID = "";
//List of insults
var INSULT_LIST = [
"Nah shut up, you bad little weapon",
"Sample insult 2",
"Sample insult 3"
];
//Setup
exports.handler = function(event, context, callback){
var alexa = Alexa.handler(event,context);
alexa.APP_ID = APP_ID;
alexa.registerHandlers(handlers);
alexa.execute();
}
var handlers = {
'LaunchRequest': function(){
this.emit('GetInsult');
},
'GetInsultIntent': function() {
this.emit('GetInsult');
},
'GetInsult' : function() {
var insultIndex = Math.floor(Math.random()*INSULT_LIST.length);
var randomInsult = INSULT_LIST[insultIndex];
//Output
var speechOutput = randomInsult;
this.emit(":tellWithCard", speechOutput, SKILL_NAME, randomInsult);
},
'AMAZON.HelpIntent' : function() {
var speechOutput = "You can say give me an insult, or, you can say exit.";
var reprompt = "What can I help you with?";
this.emit(":ask", speechOutput, reprompt);
},
'AMAZON.StopIntent' : function() {
this.emit(":tell","Goodbye!");
},
'AMAZON.CancelIntent' : function() {
this.emit(":tell","Goodbye!");
}
}
【问题讨论】:
-
能否分享来自 cloudwatch 的 Lambda 日志?
-
这些是日志,有几个,但它只是一遍又一遍,因为我已经尝试过很多次了
-
我在日志中找不到任何错误。您可以在 lambda 的开头和结尾添加一个 console.log 吗?
-
我已将我的代码添加到问题中,也许这样更容易查看是否有任何错误。这是我的 index.js
标签: amazon-web-services aws-lambda alexa alexa-skills-kit