I'm developing an application for the Google Assistant, but always when I try to get the user info, like name or location, after I get the user permissions the application crash and in the next times when I launch the application with the permissions granted crash again in the same step.
app.handle('create_user', async (conv) => {
const payload = conv.user.params.tokenPayload;
// write user name in session to use in dialogs
conv.user.params.name = payload.given_name;
const email = payload.email;
if (email) {
try {
conv.user.params.uid = (await auth.getUserByEmail(email)).uid;
} catch (e) {
if (e.code !== 'auth/user-not-found') {
throw e;
}
// If the user is not found, create a new Firebase auth user
// using the email obtained from the Google Assistant
conv.user.params.uid = (await auth.createUser({email})).uid;
}
const userDoc = dbs.user.doc(conv.user.params.uid);
const orderHistoryColl = userDoc.collection(orderHistory);
for (let i = 0; i < options.length; i++) {
await orderHistoryColl.doc(options[i]).set(
{option: options[i], count: 0});
}
}
});