I am working on chatbot using dialogflow to fetch the user's location using actions on google for which I am using the server side code as follows
const functions = require('firebase-functions');
const DialogflowApp = require('actions-on-google').DialogflowApp;
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
const requestPermission = (app) => {
app.askForPermission('To locate you', app.SupportedPermissions.DEVICE_PRECISE_LOCATION);
};
const userInfo = (app) => {
if (app.isPermissionGranted()) {
const address = app.getDeviceLocation().address;
if (address) {
app.tell(`You are at ${address}`);
}
else {
// Note: Currently, precise locaton only returns lat/lng coordinates on phones and lat/lng coordinates
// and a geocoded address on voice-activated speakers.
// Coarse location only works on voice-activated speakers.
app.tell('Sorry, I could not figure out where you are.');
}
} else {
app.tell('Sorry, I could not figure out where you are.');
}
};
const app = new DialogflowApp({request, response});
const actions = new Map();
actions.set('request_permission', requestPermission);
actions.set('user_info', userInfo);
app.handleRequest(actions);
});
Here's the screenshot of the intents am using for the same :
Once am triggering the request_permission intent, this will send an action request_permission to my application and run the helper method askForPermission(...)
according to my server-side code which will send a PLACEHOLDER_FOR_PERMISSION
response to Actions On Google that will further trigger the “To locate you, I’ll just need to get your street address from Google. Is that ok?” message and return this as a response to dialogflow but instead of that am receiving PLACEHOLDER_FOR_PERMISSION as a response in dialogflow.Can anyone please help with what am I missing here?Any suggestions....