Why isn't the document being added to the Firebase Cloud FireStore? The error message in the console is also not displayed.

'use strict'; const functions = require('firebase-functions'); const {WebhookClient} = require('dialogflow-fulfillment'); const admin = require('firebase-admin'); process.env.DEBUG = 'dialogflow:debug'; // enables lib debugging statements admin.initializeApp(functions.config().firebase); const db = admin.firestore(); const settings = {timestampsInSnapshots: true} db.settings(settings); exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => { const agent = new WebhookClient({request, response}); console.log('Dialogflow Request headers: ' + JSON.stringify(request.headers)); console.log('Dialogflow Request body: ' + JSON.stringify(request.body)); function welcome (agent) { var username = '1'; var userphone = '2'; var userquestion = '3'; db.collection('advicereq').add({ username: username, userphone: userphone, userquestion: userquestion }).then(docRef => { console.log('Document written with ID: ', docRef.id); agent.add(`Welcome to my agent!`); }).catch(error => { console.error('Error adding document: ', error); agent.add('Error adding document:'); }) } let intentMap = new Map(); intentMap.set('Default Welcome Intent', welcome); agent.handleRequest(intentMap); }); 

    0