chatHistory that backs chat memory classes like BufferMemory for a firestore.
Setup
First, install the Firebase admin package in your project:npm
npm
Project Settings page from your Firebase project and select the Service accounts tab.
Inside the Service accounts tab, click the Generate new private key button inside the Firebase Admin SDK section to download a JSON file containing your service account’s credentials.
Using the downloaded JSON file, pass in the projectId, privateKey, and clientEmail to the config object of the FirestoreChatMessageHistory class, like shown below:
collections field should match the names and ordering of the collections in your database.
The same goes for docs, it should match the names and ordering of the docs in your database.
Usage
Nested Collections
TheFirestoreChatMessageHistory class supports nested collections, and dynamic collection/doc names.
The example below shows how to add and retrieve messages from a database with the following structure: