问题
Hi i'm trying to get device location of the user by asking permission.It works fine for simulator but when i tested with google mini device getting undefined for device location in webhook request.Below is the code
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);
}
}
回答1:
You can't mix the dialogflow-fulfillment
and actions-on-google
libraries. The data types aren't necessarily going to be compatible. If you require features specific to Actions on Google, you should use actions-on-google
completely. If you require compatibility between a variety of platforms supported by Dialogflow, use dialogflow-fulfillment
.
来源:https://stackoverflow.com/questions/52833499/getting-device-location-as-empty-in-dialogflow-webhook-request