问题与空的SpeechletResponse(Alexa)

有些东西与我的AMAZON.StopIntent搞砸了。 无论我放在哪里(我试过每个教程中的所有内容),只要被调用,我就会得到“请求的技能响应出现问题”,Alexa应用程序将错误显示为“speechletresponse不能为空”。 我的项目是在JSON,而不是Java格式。

如果有人能帮忙,我会非常感激!

谢谢!

按照要求,这是什么被发送到Lambda

{ "session": { "sessionId": "SessionId.XXXXX", "application": { "applicationId": "amzn1.ask.skill.XXXXXXX" }, "attributes": {}, "user": { "userId": "amzn1.ask.account.XXXXXXX" }, "new": true }, "request": { "type": "IntentRequest", "requestId": "EdwRequestId.XXXXXX", "locale": "en-US", "timestamp": "2017-01-18T22:38:53Z", "intent": { "name": "AMAZON.StopIntent", "slots": {} } }, "version": "1.0" } 

这里是相关的代码:

 var handlers = { 'LaunchRequest': function () { this.emit('AMAZON.HelpIntent'); }, 'GetNewDogThoughtIntent': function () { this.emit('GetDogThought'); }, 'GetNewCatThoughtIntent': function () { this.emit('GetCatThought'); }, 'GetDogThought': function () { var dogthoughtIndex = Math.floor(Math.random() * DOGTHOUGHTS.length); var randomDogThought = DOGTHOUGHTS[dogthoughtIndex]; // Create speech output var speechOutput = "Your dog is thinking, " + randomDogThought; this.emit(':tellWithCard', speechOutput, "Your dog was thinking... ", randomDogThought); }, 'GetCatThought': function () { var catthoughtIndex = Math.floor(Math.random() * CATTHOUGHTS.length); var randomCatThought = CATTHOUGHTS[catthoughtIndex]; // Create speech output var speechOutput = "Your cat is thinking, " + randomCatThought; this.emit(':tellWithCard', speechOutput, "Your cat was thinking... ", randomCatThought); }, 'AMAZON.HelpIntent': function () { var speechOutput = "You can ask me for what your cat or dog is thinking, or you can say exit... Right now I can only provide thoughts for one cat or dog at a time... What can I help you with?"; var reprompt = "What can I help you with? Make sure to say if your pet is a cat or dog when you ask!"; this.emit(':ask', speechOutput, reprompt); }, 'SessionEndedRequest': function (sessionEndedRequest, session) { }, "AMAZON.StopIntent": function (shouldEndSession) { } 

我终于在再次咨询SpaceGeek教程并做了一些调整之后得到了它。 基本上,这是什么工作:

 'AMAZON.StopIntent': function () { this.emit(':tell', "Goodbye!"); 

}

关键是':tell' ,这是我以前没有的。 感谢所有回答和帮助的人!

你可以发布StopIntent代码吗? 你应该在其中调用一个speechlet响应。 例如:

 'AMAZON.StopIntent': function (shouldEndSession, response) { var speechOutput = "Goodbye"; response.tell(speechOutput); }, 

你是否正确地build立了这个回应并通过了它?

我在alexa开发人员论坛上find了此链接。 这可能有助于你的问题..

https://forums.developer.amazon.com/questions/49211/system-error-speechletresponse-was-null.html

我写这个代码在PHP中,如果有帮助

 $data = file_get_contents("php://input"); $jsonData = json_decode($data); if($jsonData->request->type === "IntentRequest"){ $IntentName = $jsonData->request->intent->name; if($IntentName === "AMAZON.StopIntent"){ $response = '{ "version" : "1.0", "response" : { "outputSpeech": { "type": "PlainText", "text": "" }, "shouldEndSession" : false } }'; echo $response; } }