我使用AWS、Lambda和Python来响应API.AI的web钩子请求。
我用这个堆栈创建了几个Google操作,它们运行得很好。
我想启动帐户链接,在谷歌主页的对话中。谷歌提供的文档假设我使用的是Node.js SDK,而我不是。
要启动帐户链接,需要在API.AI web钩子响应中返回什么?
如果一些使用Node.js的用户能够打印出他们的web钩子返回的响应对象,那么我就知道我的Lambda函数需要返回哪些参数,这就回答了这个问题。
-更新Google https://developers.google.com/actions/reference/conversation页面,非常清楚如何通过Google请求oauth2帐户信息。
但是,我使用的是API.AI,如何将我的web钩子响应格式化为API.AI,以便将所请求的帐户权限传递给Google操作?
我尝试将"expected_inputs“字段放在web钩子响应的根中,以及在"data":{"google":{.}字段中。两样都没用。
到目前为止,我们在API.AI方面的经验总的来说是积极的。这是我们目前唯一需要的功能,以至于我们无法通过当前的堆栈。
发布于 2017-02-14 19:39:05
更新:您的web钩子响应需要包含以下形式的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
先前的答复:
您可以在开发人员参考中找到JSON布局(如下所示),但是Node.js客户端库使这件事变得更加简单,看起来您可以使用在Lambda上安装npm模块。
{
"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"
}
}
]
}
]
}https://stackoverflow.com/questions/42212543
复制相似问题