Google Firestore

Integration published by Jovo | 5,925 downloads

Store user data in a Firestore database on Google Cloud

Google Firestore Database Integration

Learn how to store user specific data of your Alexa Skills and Google Actions to Google Cloud Firestore.

Tutorial: Deploy to Google Cloud

Introduction

The Firestore integration allows you to store user session data in the NoSQL service running on Google Firebase. This integration is especially convenient if you're running your voice app on Google Cloud Functions. You can find the official documentation about Firestore here: firebase.google.com/docs/firestore.

Learn more about hosting your application on Google Cloud Functions.

Configuration

Download the package like this:

Firestore can be enabled in the src/app.js file like this:

If you are using Firestore in other parts of your application and already have an intialized instance, you can just pass that into the constructor as well. This is especially helpful when using Firebase Cloud Functions. When deploying your code to Firebase Cloud Functions you don't need to provide the databaseURL and credential in the config.js file and you won't have the error related to the initializeApp method being called twice on the firebase-admin instance.

Inside your config.js file you have to set your credential and your databaseURL. You can also optionally set the collection name (default is UserData):

Using Firestore outside Google Cloud

If you use plan to use the Firestore integration while hosting your project outside Google Cloud Functions (e.g. on AWS Lambda), you have to add the following post install script to your package.json:

You need the script because the Firestore integration depends on the firebase-admin module, which depends on the grpc module. If you simply run npm install it will download the grpc binary for your node version and operating system combination, which might differ from the one Lambda expects, which is node-v48-linux-x64-glibc. The script installs the correct binary for you. Find more about that here.

Firestore Changelog

Current version might be higher than the latest changes displayed below because of updates of dependencies.

2020-09-29 [3.1.0]

3.0.11 (2020-04-06)

  • Updated Typescript to 3.8.x
  • Updated Prettier to 2.x

Committers: 2

2.x

Find the 2.x changelog here.

Join Our Newsletter

Be the first to get our free tutorials, courses, and other resources for voice app developers.