【问题标题】:API.AI for Google Home - what needs to be in webhook to initiate account-linking?Google Home 的 API.AI - webhook 中需要什么来启动帐户链接?
【发布时间】:2017-02-13 20:02:28
【问题描述】:

我正在使用 AWS Lambda 和 Python 来响应 API.AI 的 webhook 请求。

我已经使用这个堆栈创建了几个 Google 操作,它们都可以正常工作。

我想在 Google Home 对话过程中启动帐户关联。 Google 提供的文档假定我使用的是 Node.js SDK,但我没有。

需要在 API.AI webhook 响应中返回什么来启动帐户链接?

如果一些使用 Node.js 的人可以打印出他们的 webhook 返回的响应对象,以便我知道我的 Lambda 函数需要返回哪些参数,那就可以回答这个问题。

-- 更新 Google Actions API https://developers.google.com/actions/reference/conversation 的这个页面非常清楚如何通过 Google Actions API 请求 oauth2 帐户信息。

但是,我使用的是 API.AI。如何格式化对 API.AI 的 webhook 响应,以便将请求的帐户权限传递给 Google Actions?

我尝试将“expected_inputs”字段放在我的 webhook 响应的根目录和“data”:{“google”:{...}} 字段中。都没有用。

到目前为止,我们对 API.AI 的体验总体上是积极的。这是我们目前唯一无法通过当前堆栈的功能。"`

【问题讨论】:

  • 您能解释一下“帐户关联”是什么意思吗?您是否有兴趣向用户征求他们的姓名或位置的许可?还是与其他 API 链接?
  • 我希望用户允许我接收他们用来登录 Google Home 的电子邮件地址。这可以让我向用户发送一封摘要电子邮件。
  • 目前,您只能通过 Actions on Google 获取位置信息和用户名:developers.google.com/actions/develop/identity/user-info

标签: lambda dialogflow-es google-home


【解决方案1】:

更新: 您的 webhook 响应需要包含以下形式的 JSON 对象以请求权限:

{
  "speech": "...",  // ASCII characters only
  "displayText": "...",
  "data": {
    "google": {
      "expect_user_response": true,
      "is_ssml": true,
      "permissions_request": {
        "opt_context": "...",
        "permissions": [
          "NAME",
          "DEVICE_COARSE_LOCATION",
          "DEVICE_PRECISE_LOCATION"
        ]
      }
    }
  },
  "contextOut": [...],
}

目前唯一可用的权限是 NAME、DEVICE_PRECISE_LOCATION 和 DEVICE_COARSE_LOCATION。这记录在这里:https://developers.google.com/actions/reference/webhook-format#response


上一个答案:

您可以在 developer reference(转载如下)中找到 JSON 布局,但 Node.js client library 使这更容易,看起来您可以在 install npm modules on Lambda 中找到。

{
  "user": {
    "user_id": "...",
    "profile": {
      "given_name": "John",
      "family_name": "Doe",
      "display_name": "John Doe"
    },
    "access_token": "..."
  },
  "device": {
    "location": {
      "coordinates": {
        "latitude": 123.456,
        "longitude": -123.456
      },
      "formatted_address": "1234 Random Road, Anytown, CA 12345, United States",
      "city": "Anytown",
      "zip_code": "12345"
    }
  },
  "conversation": {
    "conversation_id": "...",
    "type": "ACTIVE",
    "conversation_token": "..."
  },
  "inputs": [
    {
      "intent": "assistant.intent.action.MAIN",
      "raw_inputs": [
        {
          "query": "..."
        }
      ],
      "arguments": [
        {
          "name": "destination",
          "raw_text": "SFO",
          "location_value": {
            "latlng": {
              "latitude": 37.620565,
              "longitude": -122.384964
            },
            "formatted_address": "1000 Broadway, San Francisco, CA 95133"
          }
        }
      ]
    }
  ]
}

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-04-28
相关资源
最近更新 更多