无法使用echosim.io的特定请求调用技能

问题描述 投票:1回答:1

这是Alexa技能代码:

'use strict';
const Alexa = require("alexa-sdk");

exports.handler = function(event, context, callback) {
    console.log("skill-sample-nodejs-hello-world Received an event");
    console.log("event=");
    console.dir(event);
    const alexa = Alexa.handler(event, context);
    alexa.registerHandlers(handlers);
    alexa.execute();
};

const handlers = {
    'LaunchRequest': function () {
        console.log("LaunchRequest called()");
        this.response.speak('Hello World Init!').listen("I am listening SayHelloInit");
        this.emit(':responseReady');
        //this.emit('SayHelloInit');
    },
    'HelloWorldIntent': function () {
        console.log("hello world intent called");
        this.response.speak('Hello World How are you!').listen("I am listening sayhello");
        this.emit(':responseReady');
        //this.emit('SayHello');
    },
    'AMAZON.HelpIntent': function () {
        const speechOutput = 'This is the Hello World Sample Skill. ';
        const reprompt = 'Say hello, to hear me speak.';

        this.response.speak(speechOutput).listen(reprompt);
        this.emit(':responseReady');
    },
    'AMAZON.CancelIntent': function () {
        this.response.speak('Goodbye!');
        this.emit(':responseReady');
    },
    'AMAZON.StopIntent': function () {
        this.response.speak('See you later!');
        this.emit(':responseReady');
    },
    'SessionEndedRequest': function () {
        console.log("SESSIONENDEDREQUEST");
        this.response.speak("SessionEndedRequest. Goodbye!");
        this.emit(':responseReady');
    },
    'Unhandled': function() {
        console.log("UNHANDLED");
        const message = 'Unhandled';
        this.response.speak(message).listen(message);
        this.emit(':responseReady');
    }
};

以下是一些观察到的奇怪行为:

从Amazon Developer Console中的Alexa模拟器,无法通过“启动hello world回家”来调用技能,响应是“抱歉,我不知道。”。但是在我通过“开始你好世界”调用技能之后,我可以通过“开始你好世界回家”来调用并获得响应“Hello World你好!”。

从Echosim.io,我可以通过“开始你好世界”调用技能,但我永远不会通过“开始你好世界回家”来调用。它回答“对不起,我不知道”。此外,没有任何重新发表的言论被播放出来。

从cloudwatch日志中,有时我看到发送到lambda函数的“SessionEndedRequest”,原因码为“USER_INITIATED”。我没有说“停止,取消”等。如何触发USER_INITIATED SessionEndedRequest?这在某种程度上与谴责言论从未发挥过的事实有关吗?

“回家”映射如下:

            {
              "name": "HelloWorldIntent",
              "samples": [
                  "hello",
                  "say hello",
                  "who are you",
                  "go home",
                  "hello world"
              ],
              "slots": []
            }
alexa-skills-kit
1个回答
0
投票

我看到很多帖子最近都没有得到责备。我认为SDK可能无法按照第一行中的预期构建响应。

this.response.speak(speechOutput).listen(reprompt);
this.emit(':responseReady');

尝试改为这一行。

this.emit(':ask', speechOutput, reprompt);

这应该等同于你的。

关于echosim.io的问题。你用适当的麦克风录制你的话语吗?根据我的经验,即使我使用耳机麦克风,echoism.io也很难识别我在说什么。

相反,如果可能的话,我建议使用echo设备,或者在开发者控制台中使用新引入的Test Simulator BETA。

© www.soinside.com 2019 - 2024. All rights reserved.