Learn how to store user specific data to databases with the Jovo Persistence Layer.
This is an abstraction layer for persisting data across sessions. By default, the file-based system will be used so you can start right away when prototyping locally.
You can add different database integrations in the Jovo app constructor. This is the default configuration:
This will save data with your user's
userID as a mainKey, and a
key and a
value specified by you.
The easiest way to do so is to use the user object for this:
After you saved data, you can use a
key to retrieve a
value from the database.
Again, you can use the user object for this:
This will delete a data point from the database, specified by a key.
This will delete your whole user's data (the
mainKey) from the database.
Note: This is the default database integration.
The FilePersistence integration allows you to easily store user session data in a JSON file. This is especially helpful for local development and prototyping. Data will be stored to a db.json file by default.
This sort of data persistence is enabled by default. The
db.json can be found in the the following folder:
And this is an example how the file structure looks like, with the
userID as a mainKey and some persisted data with
someValue, which can be added with
this.user().data.someKey = 'someValue';:
Tutorial: Add DynamoDB to Store User Data
The DynamoDB integration allows you to store user session data in the NoSQL service running on AWS. This integration is especially convenient if you're running your voice app on AWS Lambda. Learn more about DynamoDB here: aws.amazon.com/dynamodb.
If you're running on Lambda, you can simply integrate a DynamoDB table like this:
This will create a table with a name specified by you, and use this to store and load data. To make it work, you need to give your Lambda Role DynamoDB permissions.
You can find out more in the official documentation by Amazon: AWS Lambda Permissions Model.
In case you're hosting your voice app somewhere else, you can add DynamoDB with the following:
You can find a detailed guide by Amazon about setting up your DynamoDB for programmatic access here: Setting Up DynamoDB (Web Service).
Here are a few things you need to consider when switching from a different database to DynamoDB
"") as values: If you use them, please switch to
nullor a different value
Any specific questions? Just drop them below. Alternatively, you can also fill out this feedback form. Thank you!