Learn how to store user specific data of your Alexa Skills and Google Actions to Google Cloud Firestore.
Tutorial: Deploy to Google Cloud
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.
Download the package like this:
$ npm install --save jovo-db-firestore
Firestore can be enabled in the src/app.js
file like this:
// @language=javascript
// src/app.js
const { Firestore } = require('jovo-db-firestore');
// Enable DB after app initialization
app.use(new Firestore());
// @language=typescript
// src/app.ts
import { Firestore } from 'jovo-db-firestore';
// Enable DB after app initialization
app.use(new Firestore());
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
):
// @language=javascript
// src/config.js
module.exports = {
db: {
Firestore: {
credential: require('<path-to-credential-json-file>'),
databaseURL: '<databaseURL>',
collectionName: '<collectionName>',
},
},
// ...
};
// @language=typescript
// src/config.ts
const config = {
db: {
Firestore: {
credential: require('<path-to-credential-json-file>'),
databaseURL: '<databaseURL>',
collectionName: '<collectionName>',
},
},
// ...
};
If you use plan to use the Firestore integration while hosting your project on AWS Lambda you have to add the following post install script to your
package.json
:
"scripts": {
"postinstall": "npm install grpc --target=<lambda-function-node-version> --target_arch=x64 --target_platform=linux --target_libc=glibc"
},
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.