Dialogflow es 如何在Dialogflow聊天机器人中获取用户的当前位置?
我正在尝试获取Dialogflow中的用户位置,但到目前为止我无法获取它 我在Dialogflow中找到了一些信息,这些信息显示了如何使用谷歌帮助在Dialogflow中获取位置,如下所示。问题是,我只想用聊天机器人来做,并在那里得到回应。我也尝试了下面的代码,但仍然不起作用:Dialogflow es 如何在Dialogflow聊天机器人中获取用户的当前位置?,dialogflow-es,dialogflow-es-fulfillment,Dialogflow Es,Dialogflow Es Fulfillment,我正在尝试获取Dialogflow中的用户位置,但到目前为止我无法获取它 我在Dialogflow中找到了一些信息,这些信息显示了如何使用谷歌帮助在Dialogflow中获取位置,如下所示。问题是,我只想用聊天机器人来做,并在那里得到回应。我也尝试了下面的代码,但仍然不起作用: 'use strict'; const functions = require('firebase-functions'); const admin = require('firebase-admin'); con
'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\u permission”。我将非常感谢您的帮助或建议。Dialogflow中没有获取位置的通用解决方案。并非所有使用Dialogflow的系统都有自动传输位置的方法,其他系统通过消息使用不同的方式
Google上的操作解决方案只与Google助手配合使用。Dialogflow中没有获取位置的通用解决方案。并非所有使用Dialogflow的系统都有自动传输位置的方法,其他系统通过消息使用不同的方式 Google上的操作解决方案只与Google助手一起工作