Null SpeechletResponse 问题 (Alexa)

Issue with Null SpeechletResponse (Alexa)

我的 AMAZON.StopIntent 出了点问题。无论我放在那里什么(我已经尝试了每个教程中的所有内容),只要它被调用,我都会得到 "There was a problem with the requested skill's response" 并且 Alexa 应用程序将错误显示为 "speechletresponse cannot be null"。我的项目是 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) {
    }

我在 Alexa 开发者论坛上找到了这个 link。这可能对您的问题有所帮助..

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;
  }
}

你能post你的 StopIntent 代码吗?您应该在其中调用 speechlet 响应。例如:

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

您是否正确构建并通过了该响应?

再次查阅SpaceGeek教程并进行一些调整后,我终于明白了。基本上,这是有效的:

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

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