7

我正在编写一个 Alexa Skill,我只能将单个单词参数放入我的代码中。

这是意图模式:

    {
  "intents": [
    {
      "intent": "HeroQuizIntent",
      "slots": [
        {
          "name": "SearchTerm",
          "type": "SEARCH_TERMS"
        }
      ]
    },
    {
      "intent": "HeroAnswerIntent",
      "slots": [
        {
          "name": "SearchTerm",
          "type": "SEARCH_TERMS"
        }
      ]
    },
    {
      "intent": "AMAZON.HelpIntent"
    }
  ]
}

我的示例话语是:

HeroQuizIntent quiz me
HeroAnswerIntent is it {SearchTerm}

对于 HeroAnswerIntent,我正在检查 SearchTerm 插槽,我只在其中得到单个单词。

所以,“Peter Parker”给“Parker”,“Steve Rogers”给“Rogers”,“Tony Stark”给“Stark”。

如何在一个插槽中接受多个单词?

4

4 回答 4

3

我的技能也有同样的问题,这是我使用多个单词的技能的唯一解决方案,但是您需要检查这些插槽是否为空并将它们连接起来

意图架构:

{
  "intent": "HeroAnswerIntent",
  "slots": [
    {
      "name": "SearchTermFirst",
      "type": "SEARCH_TERMS"
    },
    {
      "name": "SearchTermSecond",
      "type": "SEARCH_TERMS"
    },
    {
      "name": "SearchTermThird",
      "type": "SEARCH_TERMS"
    }
  ]
},

示例话语

HeroAnswerIntent is it {SearchTermFirst} HeroAnswerIntent is it {SearchTermFirst} {SearchTermSecond} HeroAnswerIntent is it {SearchTermFirst} {SearchTermSecond} {SearchTermThird}

最后一个,您需要将每个单词放在 SEARCH_TERMS 插槽定义中的单独行中

即使您使用服务模拟器(技能控制台,测试选项卡)对其进行测试,也使用 AMAZON.LITERAL 有时根本不会将变量传递给技能

于 2016-06-07T05:56:19.123 回答
1

@Xanxir 提到的解决方案与较新的自定义插槽格式等效。在这种情况下,您只需在插槽类型的自定义值列表中放置多个长度示例。

于 2017-01-23T06:32:25.697 回答
0

我不得不将 Slot 类型更改为 AMAZON.LITERAL。

诀窍在于,在示例话语中,我还必须提供多个话语来展示 Alexa 应该解释的文字的最小和最大大小。这很不稳定,但有效。

这是它的参考: https ://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/alexa-skills-kit-interaction-model-reference

于 2016-04-11T02:58:48.300 回答
0

亚马逊搜索查询

所以你可以在你的话语中使用它,它会检测到用户说的所有单词,它相当准确

它会解决你的问题。

参考链接:Alexa SearcQuery

于 2018-06-26T04:33:58.530 回答