MongoDB storage provider for the Bot Framework JavaScript SDK v4. This library implements the `Storage` interface, allowing bots to persist conversation state, user state, and bot state in a MongoDB database. The current version (1.0.17) supports Node.js 13+ and is compatible with the BotBuilder v4 SDK. It exposes a simple API: create a `MongoDbStorage` instance with a MongoDB collection, then use it with `ConversationState` or `UserState`. The library provides a convenience method `getCollection()` that defaults to database `BotFramework` and collection `BotFrameworkState`, but supports custom names. Compared to the official botbuilder-azure storage, this package is community-maintained and offers a lightweight, pure-MongoDB solution without Azure dependencies.
npm install botbuilder-storage-mongodbNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Connect to MongoDB, create a MongoDbStorage instance, then write and read bot state.
Upgrade to v1+ and pass a MongoCollection object directly.
Use `new MongoClient(url).db(dbName).collection(collectionName)` to create the collection explicitly.
Always read before write to get the current eTag, or use '*' to force overwrite.
Pass `{ useUnifiedTopology: true }` to the MongoClient constructor.Always use the storage interface read/write methods; do not query the collection directly.
Use named import: `import { MongoDbStorage } from ...` or `const { MongoDbStorage } = require(...)`Pass a valid MongoCollection object: `new MongoDbStorage(collection)`
Use `mongodb://user:password@host:port/db?authSource=admin` with proper URL encoding.
Add `{ useUnifiedTopology: true }` as the second parameter to the MongoClient constructor.