Alexa服务响应包含“Speechlet响应”,其中包含一张额外的卡,不确定为什么?

时间:2017-10-25 21:21:14

标签: amazon-web-services aws-lambda alexa alexa-skills-kit

我已经创造了我的第一个测试alexa技能,所有它应该做的就是让Alexa侮辱你。 (我知道这已经创建了,但这只是一个测试) 我一直在关注一个教程,但现在当我打开我的回应技巧时,我得到的回答是“抱歉,出了点问题”。 正在调用的代码是

this.emit(“:tellWithCard”,speechOutput,SKILL_NAME,randomInsult);

这是我在服务模拟器上获得的服务响应:

    {
      "version": "1.0",
      "response": {
        "outputSpeech": {
          "ssml": "<speak> Nah shut up, you bad little weapon </speak>",
          "type": "SSML"
        },
        "card": {
          "content": "Nah shut up, you bad little weapon",
          "title": "Insulter"
        },
        "speechletResponse": {
          "outputSpeech": {
            "ssml": "<speak> Nah shut up, you bad little weapon </speak>"
          },
          "card": {
            "content": "Nah shut up, you bad little weapon",
            "title": "Insulter"
          },
          "shouldEndSession": true
        }
      },
      "sessionAttributes": {}
    }

在我接下来的教程中,语音响应不在服务响应中,是否有人知道为什么它现在包含在响应中?我不确定我的代码中是否存在错误,或者Lambda函数的工作方式是否有变化。这是对cloudwatch的回复:

    21:12:48
    START RequestId: 4085e037-b9c9-11e7-b5e8-23df701a71f2 Version: $LATEST
    
    21:12:48
    2017-10-25T21:12:48.029Z    4085e037-b9c9-11e7-b5e8-23df701a71f2    
    Warning: Application ID is not set
    
    21:12:48
    END RequestId: 4085e037-b9c9-11e7-b5e8-23df701a71f2
    
    21:12:48
    REPORT RequestId: 4085e037-b9c9-11e7-b5e8-23df701a71f2  Duration: 0.68 
    ms  Billed Duration: 100 ms Memory Size: 128 MB Max Memory Us

这是我的index.js代码:

"use strict";

//Variables
var Alexa = require("alexa-sdk");
var SKILL_NAME = "Insulter";
var APP_ID = "";

//List of insults
var INSULT_LIST = [
    "Nah shut up, you bad little weapon",
    "Sample insult 2",
    "Sample insult 3"
];


//Setup
exports.handler = function(event, context, callback){
    var alexa = Alexa.handler(event,context);
    alexa.APP_ID = APP_ID;
    alexa.registerHandlers(handlers);
    alexa.execute();
}

var handlers = {
    'LaunchRequest': function(){
        this.emit('GetInsult');
    },
    'GetInsultIntent': function() {
        this.emit('GetInsult');
    },
    'GetInsult' : function() {
        var insultIndex = Math.floor(Math.random()*INSULT_LIST.length);
        var randomInsult = INSULT_LIST[insultIndex];

        //Output
        var speechOutput = randomInsult;

        this.emit(":tellWithCard", speechOutput, SKILL_NAME, randomInsult);
    },
    'AMAZON.HelpIntent' : function() {
        var speechOutput = "You can say give me an insult, or, you can say exit.";
        var reprompt = "What can I help you with?";
        this.emit(":ask", speechOutput, reprompt);
    },
    'AMAZON.StopIntent' : function() {
        this.emit(":tell","Goodbye!");
    },
    'AMAZON.CancelIntent' : function() {
        this.emit(":tell","Goodbye!");
    }
}

2 个答案:

答案 0 :(得分:0)

第四个参数(according to amazon is this.emit(':tellWithCard', speechOutput, cardTitle, cardContent, imageObj);)imageObj,你试图在那里放一个语音字符串,我相信这就是你的alexa崩溃的原因。在那里放置图像或完全删除它。

答案 1 :(得分:0)

我已经解决了我遇到的问题。事实证明问题是我在英语(美国),尽管事实上我有一个英国的Alexa,并且在亚马逊开发者控制台上将事情改为英语(英国),一切都按预期工作。不管怎样,谢谢!