【问题标题】:How to tell Alexa to jump to a specific intent from LaunchRequest based on user input如何告诉 Alexa 根据用户输入从 LaunchRequest 跳转到特定意图
【发布时间】:2019-08-22 22:58:13
【问题描述】:

我是 Alexa 开发的新手,所以请原谅我的无知。我正在开发的 Alexa 技能需要以下内容:

用户会通过提问来唤醒技能,例如

Alexa,向营销平台询问上次活动的结果

我指的是https://developer.amazon.com/docs/custom-skills/understanding-how-users-invoke-custom-skills.html#cert-invoke-specific-request,但不太明白如何从LaunchRequest跳转到特定意图。

其中marketing platform 是技能调用,result of last campaign 是名为CampaignIntent 的技能意图的表达。

还有更多这样的意图,我想根据用户的问题来调用,例如

Alexa,请营销平台给我消息详情

我正在使用 Lambda 作为技能。目前它看起来如下:

exports.handler = (event, context, callback) => {
  try {
    if (event.request.type === 'LaunchRequest') {
      var welcomeMessage = '<speak>';
      welcomeMessage = welcomeMessage + 'Welcome to XYZ agency.';
      welcomeMessage = welcomeMessage + '</speak>';
      callback(null, buildResponse(welcomeMessage, false));
      //How can I tell Alexa to jump to CampaignIntent?
    }
    else if (event.request.type === 'IntentRequest') {
      const intentName = event.request.intent.name;

      if (intentName === 'CampaignIntent') {

        var ssmlConfirm = "<speak>";
        ssmlConfirm = ssmlConfirm + 'Hello Auto.';
        ssmlConfirm = ssmlConfirm + "</speak>";

        callback(null, buildResponse(ssmlConfirm, true));

      }
    }
  }
  catch (e) {
    context.fail(`Exception: ${e}`);
  }
};

function buildResponse(response, shouldEndSession) {
  return {
    version: '1.0',
    response: {
      outputSpeech: {
        type: 'SSML',
        ssml: response,
      },
      shouldEndSession: shouldEndSession,
    },
    sessionAttributes: {},
  };
}

CampaignIntent 没有任何插槽。它只是从第三方平台 API 获取记录。

我也提到了https://stackoverflow.com/a/48032367/1496518,但不明白如何实现...has a WHEN slot to elicit部分。

【问题讨论】:

    标签: node.js alexa-skills-kit alexa-intent alexa-interaction-model


    【解决方案1】:

    您链接的文档说,“用户可以将您的调用名称与操作、命令或问题结合起来。这会向您的技能服务发送一个 IntentRequest,其中包含与用户请求相对应的特定意图。”

    如果用户以这种方式调用您的技能,您在该用户会话的第一个请求中找到的意图将是 CampaignIntent(您定义的 IntentRequest)而不是 LaunchRequest。你不需要做任何“跳跃”。无论有或没有槽值,行为都是相同的。

    【讨论】:

      猜你喜欢
      • 2020-06-04
      • 1970-01-01
      • 2018-08-15
      • 2012-04-16
      • 1970-01-01
      • 2018-11-26
      • 2021-05-16
      • 2019-09-24
      • 1970-01-01
      相关资源
      最近更新 更多