1

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 : request permission intent

user info intent

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....

Puneet
  • 615
  • 2
  • 7
  • 17
  • So this works fine in the Actions simulator but not in the Dialogflow simulator? – Nick Felker Mar 21 '18 at 16:20
  • @NickFelker yes, this works fine for Google assistant simulator but it's not working on other integrations on dialogflow like web demo, etc. – Jyoti Gautam Mar 23 '18 at 06:38
  • 1
    Okay that's working as intended. Some features like requesting permission are only part of the Actions on Google platform, whereas it's not available to Dialogflow in general. – Nick Felker Mar 23 '18 at 17:19

1 Answers1

1

to request permission you should be on agent side like google assistance or facebook and your sample working well on google assistance only but you cannot test it on the dialgflow directly.

Mahmoud Zamel
  • 76
  • 1
  • 3