【问题标题】:Only getting single word parameters from Alexa Skills Kit仅从 Alexa Skills Kit 获取单个单词参数
【发布时间】:2016-07-28 16:31:51
【问题描述】:

我正在编写一个 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”。

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

【问题讨论】:

  • 你得到的 json 结构有什么线索吗?没有什么明显的。可能值得发布结构。
  • 好点。这是发送到 Lamda 的请求的相关部分。
  • "request": { "type": "IntentRequest", "requestId": "EdwRequestId.da0c74ea-15bd-45b9-a69e-76c523f08195", "timestamp": "2016-04-08T18:04:45Z", "intent": { "name": "HeroAnswerIntent", "slots": { "SearchTerm": { "name": "SearchTerm", "value": "Parker" } } } },
  • 所以,SearchTerm 插槽仍然只是我告诉 Alexa 的最后一个工作。似乎问题出在 Alexa 语音解释中,唯一的解决方案可能是接受多个插槽。这将是可悲的,因为它会在 lamda 函数中产生一些地狱般的逻辑。

标签: alexa alexa-skills-kit alexa-skill


【解决方案1】:

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

意图架构:

{
  "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 有时根本不会将变量传递给技能

【讨论】:

    【解决方案2】:

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

    【讨论】:

      【解决方案3】:

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

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

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

      【讨论】:

        【解决方案4】:

        AMAZON.SearchQuery

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

        它会解决你的问题。

        参考链接:Alexa SearcQuery

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2018-01-05
          • 2016-04-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2017-05-29
          • 2023-03-06
          • 2017-07-14
          相关资源
          最近更新 更多