【问题标题】:Issue with Null SpeechletResponse (Alexa)Null SpeechletResponse (Alexa) 的问题
【发布时间】:2017-05-14 20:20:03
【问题描述】:

我的 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) {
    }

【问题讨论】:

    标签: node.js alexa alexa-skills-kit


    【解决方案1】:

    在再次查阅 SpaceGeek 教程并对其进行了一些调整后,我终于得到了它。基本上,这是有效的:

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

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

    【讨论】:

      【解决方案2】:

      您可以发布您的 StopIntent 代码吗?您应该在其中调用语音响应。例如:

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

      您是否正确构建响应并传递它?

      【讨论】:

      • 我把它放进去时出现了很多错误。这与我的项目是 JSON 的事实有关吗?现在我在 StopIntent 中没有任何内容,因为我放置的任何内容要么在 Lambda 中出错,要么给出空响应。
      • 你能把你的技能代码贴出来吗?我不确定您使用的是什么语言或一切是如何构建的。谢谢! :)
      • OP 更新了相关代码。基于 SpaceGeek 模板。请注意,SessionEndedRequest 工作正常,但不是 AMAZON.StopIntent。我实际上已经尝试了那里的所有内容,所以目前我有 (shouldEndSession) 但我在 {} 和 () 中尝试了其他东西。
      • 您是否在意图架构中添加了 AMAZON.StopIntent(在线编辑技能时在交互模型部分下)?我会确保 AMAZON.StopIntent 在您的架构中,并且只是为了傻笑,我会确保您在代码中使用单引号将 AMAZON.StopIntent 括起来,就像您对所有其他意图所做的那样。
      • 我认为你最好的办法是打开一个新问题,发布你的全部代码(或链接到它),描述你遇到的问题,并确保你用节点标记问题.js(或类似的东西),所以你可以吸引一些了解该语言的人。抱歉,我无法提供更多帮助!
      【解决方案3】:

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

      【讨论】:

      • 嗨!谢谢 - 但这些建议仍然没有奏效 - 仍然得到无效响应。我所有其他意图都可以正常工作,只是 AMAZON.StopIntent。
      • 我认为您应该做出一些回应以换取停止意图请求。当 stopIntent 请求发送一些空响应或感谢响应时。
      • 我知道,但我找不到实际有效的响应代码。
      • 我在我的答案中添加了一些代码..检查是否有效。
      • 我使用 .js/JSON 而不是 php,对不起!
      猜你喜欢
      • 2020-08-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多