2016-12-30 27 views
6

東西是我的AMAZON.StopIntent搞砸了。無論我放在那裏(我已經嘗試了每個教程中的所有內容),每當它被調用時,我都會得到「請求的技能響應出現問題」,Alexa應用程序將錯誤顯示爲「speechletresponse不能爲空」。我的項目是JSON格式,而不是Java格式。問題與空的speechletResponse(Alexa)

如果有人能幫忙,我會非常感激!

謝謝!

如這裏要求就是被髮送到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) { 
    } 

回答

4

我終於在再次諮詢SpaceGeek教程並對它進行了一些調整後得到了它。基本上,這裏是什麼工作:

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

}

的關鍵是':tell',這是我以前沒有的。感謝所有回答和幫助的人!

0

我發現在Alexa上開發商論壇的鏈接。這可能會幫助您的問題..

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

嗨!謝謝 - 但這些建議仍然無法正常工作 - 仍然收到無效響應。我所有的其他意圖都可以正常工作,它只是AMAZON.StopIntent。 – Branch

+0

您能顯示您發送的回覆嗎? –

+0

已更新,謝謝。 – Branch

1

您可以發佈您的StopIntent代碼?你應該在其中調用一個語音應答。例如:

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

您是否正在構建該響應並將其傳遞?

+0

當我把它放進去時,出現了很多錯誤。它是否與我的項目是JSON有關?現在我在StopIntent中沒有任何東西,因爲我放的任何東西都會在Lambda中出錯或給出空響應。 – Branch

+0

你可以發佈你的技能代碼嗎?我不確定你在使用什麼語言,或者如何構建一切。謝謝! :) – AppleBaggins

+0

OP更新與相關的代碼。基於SpaceGeek模板。請注意,SessionEndedRequest工作正常,但不是AMAZON.StopIntent。我從字面上試了一切,所以現在我有(shouldEndSession),但我在{}和()中嘗試了其他的東西。 – Branch