【问题标题】:Alexa Skills - how to return an intent with slot values from another intent?Alexa Skills - 如何从另一个意图返回具有槽值的意图?
【发布时间】:2019-02-04 17:15:32
【问题描述】:

如何从另一个意图返回具有槽值的意图?

我想通过在另一个意图中返回它的槽值来触发一个意图。

这是我的 JSON 文件的示例:

{
  "interactionModel": {
    "languageModel": {
      "invocationName": "movie antakshari",
      "intents": [
        {
          "name": "SchoolIntent",
          "slots": [
            {
              "name": "Subject",
              "type": "subjects"
            }
          ],
          "samples": ["{subjects}"]
        },
        {
          "name": "teachersIntent",
          "slots": [],
          "samples": ["teachers"]
        },
      ],
      "types": [
        {
          "name": "subjects",
          "values": [
            {
              "name": {"value": "maths"}
            },
            {
              "name": {"value": "english"}
            }
          ]
        }
      ]
    }
  }
}

这是我的 index.js 文件:

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

    handle(handlerInput) {
        if (some condition) {
            // Here I want to return the schoolIntentHandler with a slot value maths
        }
    }
}

【问题讨论】:

  • 你想从teacherIntent触发schoolIntentHandler吗?

标签: alexa alexa-skills-kit


【解决方案1】:

您可以通过ElicitIntent 实现此目的。但是当你引出你的意图时,你的特定意图的插槽将变得清晰(重置为 null)。为了克服这个问题,在引发意图之前,以一种独特的方式将您的插槽值放入会话属性中,以将其识别为像 SLOT_key 这样的插槽。当它进入所需的意图时,从会话属性中获取槽值并将其用于您的逻辑。

【讨论】:

    【解决方案2】:

    意图调用由用户话语驱动。用户必须说些什么,这样 Alexa 服务才能将用户说的内容与模型中的意图相匹配。

    在您的情况下,您需要通过正确引导用户来调用 schoolIntent。即您需要从这里返回一个语音,让用户说出符合 schoolIntent 的内容

    handle(handlerInput) {
        if (some condition) {
            // Here I want to return the schoolIntentHandler with a slot value maths
            //
            // You need to return a speech from here that will make user to utter something that matches schoolIntent.
        }
    }
    

    【讨论】:

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