如何在Alexa开发人员控制台中解决“所请求的技能的响应有问题”

问题描述 投票:0回答:1

我正在尝试为Alexa构建一个简单的应用,其中用户说出调用名称(语音控制单位),然后说出用自定义意图(TempIntent)描述的话语(临时世界),以使用buildSpeechletResponse ie(temp request )。但是我在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输出为null。

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."
   }
  }

Image showing Alexa conversation

javascript node.js aws-lambda alexa-skills-kit
1个回答
0
投票
  1. 检查您正在使用的node.js的版本。
© www.soinside.com 2019 - 2024. All rights reserved.