Requesting User Location from Google Actions with Api.ai

天大地大妈咪最大 提交于 2019-12-03 21:34:42

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.

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

There is now another option for Java programmers working with Actions on Google. There is an open source port of the official SDK to Java/Kotlin. API is very similar, so for location it would be something like:

app.askForLocation()

https://github.com/TicketmasterMobileStudio/actions-on-google-kotlin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!