Alexa的技能 - 如何从另一个意图返回与槽值的意图是什么?

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

如何从另一个意图返回与槽值的意图是什么?

我想在另一个意图返回它的插槽值触发的意图。

这里是比如我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
        }
    }
}
alexa alexa-skills-kit
2个回答
0
投票

您可以通过ElicitIntent实现这一目标。但是,当你征求你的意图,你的插槽为特定的意图将得到清除(重置为空)。为了克服这个问题,引发意图之前把你的插槽值到会话属性以一种独特的方式,以确定这是一个插槽一个像SLOT_key。而当它进入所需的意图从会议attribue获取插槽值使用你的逻辑。


0
投票

这样做的目的调用由用户驱动的话语。用户必须说点什么,使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.
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.