Nodejs alexa-sdk返回errorMessage

时间:2017-08-07 16:34:56

标签: node.js alexa

将我的zip上传到Lambda时,我一直收到以下错误。

{
  "errorMessage": "RequestId: 890bda68-7b8d-11e7-be27-9f13acbc6057 Process exited before completing request"
}

我看了一个教程并创建了自己的代码,导致了同样的错误,所以我反而复制并粘贴了视频中的代码。 我尝试上传并创建一个Lambda服务来试图解决这个问题。 在上传的zip中,我有index.jspackage.json和模式库。

以下是代码:

'use strict';

//App Variables
var Alexa = require('alexa-sdk');
var APP_ID = ""; //We'll come back to this later
var SKILL_NAME = 'Mirror Mirror';

//List of compliments to be later given in a random order
var COMPLIMENT_LIST = [
    "Damn son, you're looking mighty fine today.",
    "Wow! You made an Alexa Skill. You're smarter than I thought!",
    "If you were a food, you'd be an endless supply of Cheesecake.",
    ];

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

//Intent handlers that can be triggered.
var handlers = {
    'LaunchRequest': function () {
        this.emit('GetMirrorMirror');
    },
    /*
        When a user says a recognised phrase to Alexa the GetMirrorMirrorIntent is triggered
        This picks a random compliment from the array above and emits the :tellWithCard event.
        This event shows a card within the Amazon Echo app, and outputs the speech from speechOutput.
    */
    'GetMirrorMirrorIntent': function () {
        this.emit('GetMirrorMirror');
    },
    'GetMirrorMirror': function () {
        // Get a random compliment from the COMPLIMENTS_LIST array
        var complimentIndex = Math.floor(Math.random() * COMPLIMENT_LIST.length);
        var randomCompliment = COMPLIMENT_LIST[complimentIndex];

        // Output
        var speechOutput = "Your compliment: " +  randomCompliment;

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

1 个答案:

答案 0 :(得分:-1)

1)***在第5行“APP_ID”为空白。您需要将此替换为您的技能名称旁边的Alexa开发者控制台中的技能ID。

例如:

var APP_ID = "amzn1.ask.skill.058ff9ec-2f5e-47c1-99fd-914581e9a41f";

2)此外,您是否运行节点来安装依赖项。你的帖子说你有“模式”库。这相当于文件夹node_modules吗?如果这是您第一次使用Alexa-SDK,则需要运行节点以下载依赖项。

3)另一个想法。如果您要上传到lambda,如果您说保存和测试,它将运行测试事件。您需要在蓝色测试按钮旁边的下拉列表中配置该测试事件。使用Alexa Developer Console中的测试工具输入一个uterance来生成JSON对象。然后,您可以将JSON复制到lambda中的测试事件中。注意:此JSON将包含Alexa技能的App ID,使我们回到可能的错误#1。 Lambda将仅针对来自给定应用程序的请求执行,以便其他程序员无法调用您的函数。