我正在尝试为Alexa构建一个简单的应用,其中用户说出调用名称(语音控制单位),然后说出用自定义意图(TempIntent)描述的话语(临时世界),以使用buildSpeechletResponse ie(temp请求)。 但是我在Alexa开发人员控制台的“测试”选项卡中收到“请求的技能的响应有问题”错误。
我已经尝试过更改意图名称,调用名称,函数名称,但是没有任何作用。
//This is index.js file lambda function
function onLaunch(launchRequest, session, response)
{
var output = 'Welcome to Temp World';
var reprompt = 'Type temp world';
response(session.attributes,
buildSpeechletResponseWithoutCard(output, reprompt,false));
console.log("onLaunch requestId=" + launchRequest.requestId
+ ", sessionId=" + session.sessionId);
}
function onIntent(intent, session, response) {
console.log("onIntent requestId=" + intent.requestId
+ ", sessionId=" + session.sessionId);
var intent = intentRequest.intent,
intentName = intentRequest.intent.name;
if(intentName == 'TempIntent') {
handleTempRequest();
}
else {
throw "Invalid intent";
}
}
function handleTempRequest()
{
buildSpeechletResponse("", "welcome to temp world", "", true);
}
function buildSpeechletResponse(title, output, repromptText,
shouldEndSession) {
return {
outputSpeech: {
type: "PlainText",
text: output
},
card: {
type: "Simple",
title: title,
content: output
},
reprompt: {
outputSpeech: {
type: "PlainText",
text: repromptText
}
},
shouldEndSession: shouldEndSession
};
}
我希望输出为“欢迎来到临时世界”,但JSON输出为空。
JSON输入为
"request": {
"type": "SessionEndedRequest",
"requestId": "amzn1.echo-api.request.c78c093c-eb05-4eaa-8f23-16037059e61f",
"timestamp": "2019-05-09T12:23:34Z",
"locale": "en-US",
"reason": "ERROR",
"error": {
"type": "INVALID_RESPONSE",
"message": "An exception occurred while dispatching the request to the skill."
}
}
答案 0 :(得分:0)