Google Actions SDK 忽略了可能的意图?

Google Actions SDK ignoring possibleIntents?

我在 actions.json:

中定义了这样的操作
{
  "description": "foo description",
  "name": "FooAction",
  "fulfillment": {
    "conversationName": "my-app"
  },
  "intent": {
    "name": "FooIntent",
    "trigger": {
      "queryPatterns": [
        "foo",
      ]
    }
  }
}

触发 adding actions.intent.MAIN 时,我的服务器响应如下所示:

{
  "expectUserResponse": true,
  "expectedInputs": [
    {
      "inputPrompt": {
        "richInitialPrompt": {
          "items": [
            {
              "simpleResponse": {
                "textToSpeech": "Welcome to My App! What would you like to do?",
                "displayText": "Welcome to My App! What would you like to do?"
              }
            }
          ],
          "suggestions": []
        }
      },
      "possibleIntents": [
        {
          "intent": "FooIntent"
        }
      ]
    }
  ],
  "conversationToken": "123"
}

问题:

当用户说 "Talk to My App" 然后响应 "foo" 时,为什么我只返回 actions.intent.TEXT 意图?

但是,当用户说 "Ask My App to foo"(没有触发 actions.intent.MAIN)时,我得到 FooIntent

我做错了什么?谢谢!

您没有做错任何事 - 这正是您使用 actions.json 和 Actions SDK 时的工作原理。自定义意图 用于 initial triggering and, to a lesser degree, for speech biasing

当用作初始触发的一部分时,您将获得匹配回来的意图。但您只会获得一个自定义意图名称作为初始意图的一部分。

对于以后的意图,您通常会获得 actions.intent.TEXT 意图(例外情况是您使用选项或其他一些内部响应类型)。请求自定义意图之一将有助于塑造 STT 解释器处理语音的方式,但它仍将作为 actions.intent.TEXT.

返回

通常 - 这是所需的行为。 Actions SDK 主要用于您已经拥有自然语言处理器并且您最希望只将文本发送到该 NLP 的情况。然后,您的 NLP 将根据文本确定要采取的行动。

如果您没有 NLP,我建议您使用一个。通过 Actions 控制台直接支持 Dialogflow,但是现在大多数 NLP 都描述了如何将它们与 Google 上的 Actions 一起使用,如果你想使用不同的控制台的话。