Я работаю над изучением Dialogflow с помощью Google Actions, и я немного растерялся с новым v2 actions-on-google.
Я пытаюсь найти местоположение устройства, однако способ, которым ямысль была верна, возвращается неопределенным.
Я чувствую, что упускаю что-то простое, но я не смог его найти.
Код:
const functions = require('firebase- functions');
const { dialogflow, Permission } = require('actions-on-google');
const app = dialogflow();
app.intent('create_log', conv => {
conv.ask(new Permission({
context: 'To locate you',
permissions: 'DEVICE_PRECISE_LOCATION'
}));
});
app.intent('user_info', (conv, params, granted) => {
if (granted) {
const coordinates = app.getDeviceLocation().coordinates;
if (coordinates) {
conv.close(`You are at ${coordinates}`);
} else {
// Note: Currently, precise locaton only returns lat/lng coordinates on phones and lat/lng coordinates
// and a geocoded coordinates on voice-activated speakers.
// Coarse location only works on voice-activated speakers.`enter code here`
conv.close('Sorry, I could not figure out where you are.');
}
} else {
conv.close('Sorry, I could not figure out where you are.');
}
});