如何在API.ai中请求用户的位置?

编程入门 行业动态 更新时间:2024-10-09 10:25:49
本文介绍了如何在API.ai中请求用户的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用api.ai创建一个代理并将PHP脚本用作Webhook。

I'm creating an agent using api.ai and using a PHP script as a webhook. The documentation doesn't make it clear on how to do it, but I'm wanting to request permission to the user's coarse location so they won't have to provide their location for requests.

I've tried echo-ing the JSON they mention, and putting it in as a custom payload for the default welcome intent, but neither of those seem to prompt me for permission to use my location.

How do I ask a user for permission to get their location?

EDIT: If I set my PHP script to respond to intent.welcome with the following JSON:

{ "data": { "google": { "expectUserResponse": true, "systemIntent": { "intent": "actions.intent.PERMISSION", "data": { "@type": "type.googleapis/google.actions.v2.PermissionValueSpec", "optContext": "To provide an accurate experience, ", "permissions": ["DEVICE_PRECISE_LOCATION"] } } } } }

The app asks me "To provide an accurate experience, , I'll just need to get your street address from Google. Is that ok?"

However if I say "yes", then the app keeps asking things like "Sorry, could you say that again?", so I can't actually get it to do anything.

解决方案

You need to create a new Intent with the Event set to actions_intent_PERMISSION. (See image below.)

When this Event is triggered, your webhook will be called with the JSON originalRequest.data.device.location field in the request body populated with the location information you've requested.

更多推荐

如何在API.ai中请求用户的位置?

本文发布于:2023-11-28 04:53:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1641029.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:位置   用户   如何在   ai   API

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!