dialogflow-es - 如何在 Dialogflow 聊天机器人中获取用户的当前位置?
问题描述
我正在尝试在 Dialogflow 中获取用户位置,但到目前为止我无法获取它。
我找到了显示如何使用 Google 帮助在 Dialogflow 中获取位置的信息,例如本文。问题是我只想用聊天机器人来做这件事并在那里得到回应。我也尝试了下面的代码,但仍然无法正常工作:
'use strict';
const functions = require('firebase-functions');
const admin = require('firebase-admin');
const {WebhookClient} = require('dialogflow-fulfillment');
const {Card, Suggestion} = require('dialogflow-fulfillment');
const {Permission} = require('actions-on-google');
process.env.DEBUG = 'dialogflow:debug'; // enables lib debugging statements
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
const agent = new WebhookClient({ request, response });
console.log('Dialogflow Request headers: ' + JSON.stringify(request.headers));
console.log('Dialogflow Request body: ' + JSON.stringify(request.body));
function requestPermission(agent) {
agent.requestSource = agent.ACTIONS_ON_GOOGLE;
let conv = agent.conv();
console.log('conv '+conv);
conv.ask(new Permission({
context: 'to locate you',
permissions: 'DEVICE_PRECISE_LOCATION',
}));
agent.add(conv); // Please add this
}
function welcome(agent) {
agent.add(`Welcome to my agent!`);
}
function fallback(agent) {
agent.add(`I didn't understand`);
agent.add(`I'm sorry, can you try again?`);
}
let intentMap = new Map();
intentMap.set('Default Welcome Intent', welcome);
intentMap.set('Default Fallback Intent', fallback);
intentMap.set('request_permission', requestPermission);
agent.handleRequest(intentMap);
});
我添加了一个意图调用“request_permission”。我将不胜感激任何帮助或建议。
解决方案
Dialogflow 中没有通用的解决方案来获取位置。并非所有使用 Dialogflow 的系统都有自动传输位置的方法,其他系统通过消息使用不同的方法。
Actions on Google 的解决方案仅适用于 Google 助理。
推荐阅读
- netsuite - “Suite-let 外部链接的权限访问”
- ruby - 如何在 Ruby 中测试初始化参数的数量
- angular - 基于Angular中的动态表单动态创建单选按钮
- python - Python数据框问题?
- python - Pygame-使子弹朝光标方向射击
- android - 如何解决无法获取提供程序 androidx.lifecycle.ProcessLifecycleOwnerInitializer
- django - DRF:调用时会发生什么验证
。节省()? - cassandra - Cassandra Appender - 如何仅记录错误消息?
- git - 现实世界中的 git 回滚,在工作环境中
- python - 将月份和年份转换为日期时间