dialogflow-es - 在 dialogflow webhook 请求中获取设备位置为空
问题描述
嗨,我正在尝试通过询问权限来获取用户的设备位置。它适用于模拟器,但是当我使用 google mini 设备进行测试时,webhook 请求中的设备位置未定义。下面是代码
const {Permission} = require('actions-on-google');
const {WebhookClient} = require('dialogflow-fulfillment');
const agent = new WebhookClient({ request: req, response: res });
conv.ask(new Permission({context:'To Locate You',permissions:'DEVICE_COARSE_LOCATION'}));
function userinfo(agent){
var conv=agent.conv();
var resp=conv.arguments.get('PERMISSION');
console.log(conv.device.location);
if(resp){
var country=conv.device.location.country;
var speech="you are located in "+country;
conv.ask(speech);
agent.add(conv);
}else{
conv.ask('Sorry, I could not figure out where you are');
agent.add(conv);
}
}
解决方案
您不能混合使用dialogflow-fulfillment
和actions-on-google
库。数据类型不一定是兼容的。如果您需要特定于 Actions on Google 的功能,则应actions-on-google
完全使用。如果您需要 Dialogflow 支持的各种平台之间的兼容性,请使用dialogflow-fulfillment
.
推荐阅读
- python - 使用 Python 在 Linux 中仅删除具有指定权限的文件
- apache-spark - pyspark 仅在第二个表有条目时才加入 2 个表并更改列值
- react-native - React 无法识别 DOM 元素上的 `enterKeyHint` 属性
- swift - 捕获使用 ! 引发的错误 迅速
- node.js - 在 node-db-migrate (PostgreSQL) 中使用新创建的数据库进行迁移
- fragment - 片段内的Textview和活动内的片段
- node.js - Bullmq 手动重试已完成的作业
- python - 为什么 Pandas 不能从行数据中删除未知字符?
- javascript - 如何将对象与模型对象匹配并创建缺失的属性
- python - python将.txt/list 2文件连接到一个新文件中