使用 Api.ai 从 Google Actions 请求用户位置

2023-12-31

Google Actions 可以为您提供用户的位置、姓名和其他一些详细信息。如果没有 Nodejs SDK,如何在 Api.ai 上完成此操作? Google 的所有示例都使用 Nodejs sdk。

根据对话API https://developers.google.com/actions/reference/conversation只需将正确的 json 放入响应中即可,但是尚不清楚如何让 Api.ai 填写此 json。

我读过文档在这里 https://developers.google.com/actions/develop/identity/user-info#accessing_permissioned_data_in_apiai,但我仍然不清楚。

示例代码或更详细的文档对于非 Nodejs 开发人员来说非常有用。我正在使用 Java 工作,但是对 Api.ai 如何为 Google Actions 构建响应 json 的良好解释将对所有语言的开发人员有所帮助。


你得研究API.AI HTTP APIhere https://docs.api.ai/docs/reference。作为参考,尝试设置节点示例 - 这样您就可以看到正在运行的 JSON 文件。

对于权限尝试名称 通灵者 https://github.com/actions-on-google/apiai-name-psychic-nodejs例子。

您的传出 JSON 将类似于以下内容:

{
  "contextOut": [
    {
      "lifespan": 100, 
      "name": "_actions_on_google_", 
      "parameters": {}
    }, 
    {
      "lifespan": 1, 
      "name": "requesting_permission", 
      "parameters": {}
    }
  ], 
  "data": {
    "google": {
      "expect_user_response": true, 
      "is_ssml": false, 
      "no_input_prompts": [], 
      "permissions_request": {
        "opt_context": "To send you something", 
        "permissions": [
          "DEVICE_PRECISE_LOCATION"
        ]
      }
    }
  }, 
  "speech": "PLACEHOLDER_FOR_PERMISSION"
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

使用 Api.ai 从 Google Actions 请求用户位置 的相关文章

随机推荐