【问题标题】:Calling Another Alexa intent from within LaunchRequest从 LaunchRequest 中调用另一个 Alexa 意图
【发布时间】:2017-12-29 23:56:19
【问题描述】:

我正在开发一项 Alexa 技能,当用户通过 LaunchRequest 打开该技能时,我想将他重定向到一个意图。

  • 用户说Open xyz skill
  • LaunchRequest 收到此请求并将请求转发给另一个意图。this.emit('AnotherIntent')
  • AnotherIntent 有一个运行所需的 SLOT。
  • 我已根据需要设置了 SLOT,AnotherIntent 在单独调用时确实可以正常工作。

但是,当我启动技能并尝试从其中调用AnotherIntent(如上面第 2 步所述)时,Alexa 技能无法启动。

还有一点需要注意的是,当我在此场景的技能构建器中测试相同的 Alexa 技能时,输出 json 正确地向我显示了被引出的 SLOT。不确定当我尝试从 Echo 设备运行它时发生了什么。

我正在使用 NodeJS 和 Lambda 来部署我的 Alexa 处理程序。

任何帮助将不胜感激。

基于评论的进一步参考 -

处理程序 -

var handlers = {
'LaunchRequest': function () {
    console.log("LaunchRequest::" + JSON.stringify(this.event.request));
    this.emit('fooIntent');
},
'SessionEndedRequest': function () {
    console.log('session ended!');
},
'fooIntent': function () {
    const intentObj = this.event.request.intent;
     if (!intentObj || (intentObj && !intentObj.slots.WHEN.value)) {
        console.log('fooIntent::UserId' + this.event.session.user.userId);
        const slotToElicit = 'WHEN';
        const speechOutput = 'Ask a question here ?';
        const repromptSpeech = speechOutput;
        console.log("emitting elict now");
        this.emit(':elicitSlot', slotToElicit, speechOutput, repromptSpeech);   
    } else {
        // SLOT is filled, let's query the database to get the value for the slot.
        console.log("fooIntent intent:something is requested for " + this.event.request.intent.slots.WHEN.value);
        // All the slots are filled (And confirmed if you choose to confirm slot/intent)
       fooIntentFunction(this,this.event.request.intent.slots.WHEN.value);
    }
 },
'AMAZON.HelpIntent': function () {
    var speechOutput = "Need to come up with one.";
    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!');
}

};

在 LaunchRequest 中捕获的 JSON 请求

{
"type": "LaunchRequest",
"requestId": "amzn1.echo-api.request.972bb705-d181-495e-bf60-991f2bd8fbb1",
"timestamp": "2017-12-30T21:35:21Z",
"locale": "en-US"
}

从 LaunchRequest 调用时在 Intent 中捕获的 JSON 请求。它表明intent 没有设置。我相信这就是为什么当我尝试在如上所示的 fooIntent 实现中发出 elicit 时它一直失败的原因。

{
    "type": "LaunchRequest",
    "requestId": "amzn1.echo-api.request.972bb705-d181-495e-bf60-991f2bd8fbb1",
    "timestamp": "2017-12-30T21:35:21Z",
    "locale": "en-US"
}
  • 阿米特

【问题讨论】:

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


    【解决方案1】:

    如Amazon's documentation 中所述,对话界面旨在填充特定意图的所有必需槽:

    问题和答案旨在收集和确认所有意图所需插槽的值。对话一直持续到意图所需的所有位置都被填满并得到确认。

    在您的情况下,用户的请求不是意图(即IntentRequest 类型),而是LaunchRequest。因此,即使它是由意图处理程序处理的,它也没有交互模型,也没有可引出的槽。

    你应该通过深度调用让你的技能按预期工作,比如

    Alexa,告诉 xyz 技巧给我做三明治

    (如果三明治意图,或者在您的情况下是 fooIntent,有一个 WHEN 插槽要引出)。

    希望这会有所帮助!

    【讨论】:

    • 谢谢。我没有看到this.event.request.intent.slots.foo.value 在我从launchrequest 中调用的意图中可用。用我在控制台中看到的请求以及处理程序的一些代码更新了我上面的问题。
    • 嗨@amit,我扩展了我的答案,所以它现在应该涵盖你的情况。如果它解释了你的技能行为,请告诉我!
    • 您好,谢谢您的回复。在昨天阅读文档后,我推断出同样的结果。现在我要求用户从 LaunchRequest 中调用一个 Intent 并带有简短的欢迎消息。然而,如果能够从request 调用intent 会更好。我必须说我喜欢对话和委托模型。
    【解决方案2】:

    试试这个,

    this.emitWithState("IntentName");
    

    希望这会有所帮助。一切顺利:)

    【讨论】:

      【解决方案3】:

      从另一个意图调用一个意图可以简单地使用以下sn-p - \ this.emit("意图名称")

      在您的第一个意图的响应中,提供您要调用的意图的名称。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-08-02
        • 1970-01-01
        • 1970-01-01
        • 2023-01-12
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多