我的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) {
}
答案 0 :(得分:4)
我在再次咨询SpaceGeek教程并对其进行一些调整后终于得到了它。基本上,这是有效的:
'AMAZON.StopIntent': function () {
this.emit(':tell', "Goodbye!");
}
关键是':tell'
,我以前没有。感谢所有回答和帮助的人!
答案 1 :(得分:1)
我在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;
}
}
答案 2 :(得分:1)
你可以发布StopIntent的代码吗?您应该在其中调用speechlet响应。例如:
'AMAZON.StopIntent': function (shouldEndSession, response) {
var speechOutput = "Goodbye";
response.tell(speechOutput);
},
您是否正确构建了该响应并通过了它?