1

I want to use Firestore in my DialogFlow bot but it shows certain errors. This is my index.js code:

function writeToDb () {
    console.log(`Inside writeToDb`);
    // Get parameter from Dialogflow with the string to add to the database
    const databaseEntry = {
        'eMail':'shashank@gmail.com'
    };

    console.log(databaseEntry);
    // Get the database collection 'dialogflow' and document 'agent' and store
    // the document  {entry: "<value of database entry>"} in the 'agent' document
    const dialogflowAgentRef = db.collection('dialogflow').doc('agent');
    return db.runTransaction(t => {
      t.set(dialogflowAgentRef, {entry: databaseEntry});
      return Promise.resolve('Write complete');
    }).then(doc => {
      agent.add(`Wrote "${databaseEntry}" to the Firestore database.`);
    }).catch(err => {
      console.log(`Error writing to Firestore: ${err}`);
      agent.add(`Failed to write "${databaseEntry}" to the Firestore database.`);
    });
  }

This is my package.json:

{
  "name": "dialogflowFirebaseFulfillment",
  "description": "This is the default fulfillment for a Dialogflow agents using Cloud Functions for Firebase",
  "version": "0.0.1",
  "private": true,
  "license": "Apache Version 2.0",
  "author": "Google Inc.",
  "engines": {
    "node": "8"
  },
  "scripts": {
    "start": "firebase serve --only functions:dialogflowFirebaseFulfillment",
    "deploy": "firebase deploy --only functions:dialogflowFirebaseFulfillment"
  },
  "dependencies": {
    "actions-on-google": "^2.2.0",
    "firebase-functions": "^2.0.2",
    "dialogflow": "^0.6.0",
    "dialogflow-fulfillment": "^0.5.0",
    "i18n" : "^0.8.4",
    "@google-cloud/firestore": "^0.16.1",
    "firebase-admin": "^6.0.0"
  }
}

And these are the errors I am getting :

Warning, estimating Firebase Config based on GCLOUD_PROJECT. Initializing firebase-admin may fail
Billing account not configured. External network is not accessible and quotas are severely limited. 
Configure billing account to remove these restrictions

I have already made a 'dialogflow' collection and an 'agent' document in it in my firestore.

Shashank Gupta
  • 315
  • 1
  • 4
  • 16

1 Answers1

1

Neither of these are errors, and shouldn't be preventing your webhook fulfillment from working.

The "estimating Firebase Config" error just says that you haven't explicitly set a Firebase configuration, so it is making some assumptions based on the environment - most notably, that you're working in a Cloud Function, so it is assuming the same project and access to other project default settings. If you're using the admin to access the database in the same project, this should be fine.

The message about "Billing account not configured" means just that - you're using the Spark Plan by default which has limitations on how many calls it can make per day and can only access Google's network. Since it looks like your code is just using Firestore, this shouldn't be a problem, but if you needed to access outside the network (or when your usage gets very high), you would need to upgrade to the Blaze Plan, which includes the free tier of the Spark Plan, but allows external network access.

Prisoner
  • 49,922
  • 7
  • 53
  • 105