Q: Daily update based on user location In a Google Actions app using dialogflow, I'm working on setting up a daily update with the goal of pulling the data based on the users location. I assume to do this I'll need to ask the user for permission to access their location information. 
Which of these intentions would be the right place to ask for the users location?


// what is the best place to ask a user for access to their location in this scenario?
function locateUser(conv) {
    conv.ask(new Permission({
        context: 'To locate you',
        permissions: 'DEVICE_PRECISE_LOCATION'
    }));
}

// initial invocation: "i want the daily weather forecast"
app.intent('daily_weather_updates', (conv) => {
    conv.ask(new Suggestions('Send daily weather forecast.'));
});

app.intent('daily_weather_updates.update', (conv) => {
    const intent = conv.arguments.get('UPDATE_INTENT');
    conv.ask(new RegisterUpdate({
        intent: 'get_daily_weather',
        frequency: 'DAILY'
    }));
});

app.intent('daily_weather_updates.finish', (conv, params, registered) => {
    if (registered && registered.status === 'OK') {
        conv.close(`Ok, I'll start giving you daily updates.`);
    } else {
        conv.close(`Ok, I won't give you daily updates.`);
    }
});

app.intent('get_daily_weather', (conv) => {
    Weather.getDailyWeather().then((response) => {
        conv.close(response);
    });
});



A: It depends on what weather you think the user will want. The weather at a single, specific, location where they were when they setup the notification, or the weather at the location where they are when they acknowledge the notification.
If you are expecting this to happen at the same location, you would probably want to do it in one of two places:


*

*Before you trigger the "daily_weather_updates" Intent.

*As part of the response to the "daily_weather_updates.finish" Intent.


You don't want to do this at any of the intermediary ones, since they are being asked questions related to setting up the notification. I would lean towards the first one, since if they decline the permission, you don't need to go through the notification setup. In either of these handlers, you'll want to store the location returned since it only sends you the information when they respond to the permission.
If you want to report their weather at the "current" location when they respond to the notification, you'll want to do it in the handler for whatever Intent you setup for when they acknowledge the notification. You currently have this set to "get_daily_weather", but you'll need a different Intent to ask for permission, and then one to report on the weather once you have it. In this scenario, you would only save the location for the session, since you're expecting it to change.
Keep in mind that the Assistant won't give you the location unless you ask for it. So if you do want to use it for a later conversation (either because you're just asking for it once, or you want to use it as a default for later), you will need to store it.
