使用Api.ai从Google Actions请求用户位置 [英] Requesting User Location from Google Actions with Api.ai

查看:74
本文介绍了使用Api.ai从Google Actions请求用户位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Google操作可以为您提供用户的位置,名称和其他一些详细信息。没有nodejs SDK的情况下如何在Api.ai上完成? Google的所有示例均使用Nodejs sdk。

Google Actions can provide you with the user's location, name, and few other details. How can this be done on Api.ai without the nodejs SDK? All examples from Google are using the Nodejs sdk.

根据会话Api 只是将正确的json放入响应中,但是还不清楚如何获取Api.ai来填充此json。

According to the Conversation Api it is just a matter of putting the correct json in the response, however it is unclear how to get Api.ai to fill in this json.

我已在此处阅读文档,但仍不清楚。

I've read the docs here , but am still unclear.

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

Sample code, or more detailed documentations, would be great for the non nodejs developers. I'm working in Java, however a good explanation of how Api.ai builts the response json for Google Actions would be helpful for developers of all languages.

推荐答案

您必须在此处中研究API。作为参考,尝试设置节点示例-这样您可以看到实际的JSON文件。

You have to study the API.AI HTTP API here. As a reference, try to setup the node examples - this way you can see the JSON files in action.

对于权限,请尝试

For the permissions try the Name Psychic example.

您的传出JSON将如下所示:

Your outgoing JSON will be something like this:

{
  "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"
}

这篇关于使用Api.ai从Google Actions请求用户位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆