Alexa Skills Kit:如何从ASK sdk V2中的另一个意图调用自定义意图

问题描述 投票:2回答:3

嗨,我几个月来一直在使用和开发Alexa的技能。最近我更新了问问题sdk版本2.我发现一切都很酷并且无处可去。

我现在找不到发出意图的方法。像之前一样,我们可以通过以下方式从另一个Intent调用Intent:

this.emitWithState(<intent name here>);

有人知道如何在sdk V2中实现这一点吗?

任何帮助将受到高度赞赏。

alexa alexa-skills-kit alexa-skill alexa-app
3个回答
3
投票

这样做

const FirstIntentHandler = {
  canHandle(handlerInput) {
    return handlerInput.requestEnvelope.request.type === 'IntentRequest'
      && handlerInput.requestEnvelope.request.intent.name === 'FirstIntentHandler';
  },
  handle(handlerInput) {

    // some code
    return SecondIntentHandler.handle(handlerinput);
  },
};

0
投票

如果您的技能交互模型具有对话框模型,则可以通过意图链接执行上述操作。 Intent链接允许您的技能代码从任何意图开始对话管理,包括LaunchRequest。您可以使用Dialog.Delegate进行链接意图,如下所示:

.addDelegateDirective({
    name: 'OrderIntent',
    confirmationStatus: 'NONE',
    slots: {}
 })

以下是意图链接的官方发布博客:https://developer.amazon.com/blogs/alexa/post/9ffdbddb-948a-4eff-8408-7e210282ed38/intent-chaining-for-alexa-skill

我还写了一个实现相同的示例:https://github.com/akhileshAwasthi/Alexa-Intent-chaining


-2
投票

干脆做

this.emit(<intent_name>)

将工作。

const handlers = {
  'LaunchRequest': function () {
    this.emit('HelloWorldIntent');
  },

  'HelloWorldIntent': function () {
    this.emit(':tell', 'Hello World!');
  }
};
© www.soinside.com 2019 - 2024. All rights reserved.