从LaunchRequest内调用另一个Alexa意图 [英] Calling Another Alexa intent from within LaunchRequest

查看:132
本文介绍了从LaunchRequest内调用另一个Alexa意图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一项Alexa技能,当用户通过LaunchRequest打开该技能时,我希望将其重定向到一个意图。

I am working on an Alexa skill where I would like to redirect user to one intent when he opens the skill via LaunchRequest.


  • 用户说开启xyz技能

  • LaunchRequest收到此请求并将请求转发给另一个意图。 this.emit( ''AnotherIntent')

  • AnotherIntent 具有其功能所需的插槽。

  • 我已经根据需要设置了SLOT,并且 AnotherIntent 单独调用时确实可以很好地工作。

  • User says Open xyz skill
  • LaunchRequest receives this and forwards the request to another intent.this.emit('AnotherIntent')
  • AnotherIntent has a SLOT which is required for its functioning.
  • I have setup the SLOT as required and AnotherIntent does work perfectly fine when invoked on its own.

但是,当我启动该技能并尝试如上面的步骤2所述从其中调用 AnotherIntent 时,Alexa技能无法执行发射。

However when I Launch the skill and tries to call AnotherIntent from within it as mentioned in Step 2 above, Alexa skill fails to launch.

还要注意的一件事是,当我在这种情况下从技能生成器中测试相同的Alexa技能时,输出json正确显示了被引出的SLOT。不知道当我尝试从Echo设备运行它时发生了什么。

One more thing to note is when I Test the same Alexa skill from within the skill builder for this scenario, the output json correctly shows me the SLOT being elicited. Not sure what is happening when I am trying to run it from Echo device.

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

I am using NodeJS and Lambda to deploy my Alexa handlers.

任何帮助将不胜感激。

根据评论提供的其他参考-

Further reference based on the comment -

处理程序-

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请求

JSON Request captured in LaunchRequest

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

从LaunchRequest调用时,在Intent中捕获的JSON请求。它表明当时未设置意图。我认为这就是为什么当我尝试在fooIntent实现中发出隐含提示时,它仍然会失败的原因。

JSON Request captured in the Intent when invoked from LaunchRequest. It shows that intent is not set then. I believe that is why it keeps failing when I try to emit elicit in the fooIntent implementation as shown above.

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




  • 授予

  • 推荐答案

    亚马逊的文档,对话框界面旨在满足所有必需条件特定意图的插槽:

    As specified in Amazon's documentation, the dialog interface is meant to fill all required slots of a specific intent:


    这些问题和答案旨在收集并确认所有意图插槽所需的值。对话将一直持续到意图所需要的所有插槽都已填满并确认。

    The questions and answers are intended to gather and confirm values for all of the intent’s required slots. The conversation continues until all slots needed for the intent are filled and confirmed.

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

    In your case, the user's request is not an intent (i.e. of the IntentRequest type), but a LaunchRequest. As such,it has no interaction model and no slots to elicit, even though it is processed by an intent handler.

    您应该使自己的技能按预期使用像

    You should get your Skill to work as intended with a deep invocation, like


    Alexa这样的深层调用,告诉xyz技能让我成为三明治

    Alexa, tell xyz skill to make me a sandwich

    (如果使用三明治意图,或者在您的情况下为 fooIntent ,则在插槽即可引发。)

    (if the sandwich intent, or in your case the fooIntent, has a WHEN slot to elicit).

    希望这会有所帮助!

    这篇关于从LaunchRequest内调用另一个Alexa意图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆