Registry / storage / botbuilder-storage-redis

botbuilder-storage-redis

JSON →
library1.1.2jsnpmunverified

Implements Redis-based state storage for Microsoft Bot Framework V4 (botbuilder-js), enabling scalable, persistent bot state management. Version 1.1.2 is current, with a stable API and no recent updates. Key differentiator: provides TTL-based automatic expiration for conversation state, unlike the built-in memory store. Requires Node.js 12+ and a Redis server. Supports both CommonJS and ESM usage.

npm install botbuilder-storage-redis
INSTALL
IMPORT
SIG · BOTBUILDER-STORAGE
B
botbuilder-storage-redis
storagejavascriptv1.1.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

RedisDbStorage
import { RedisDbStorage } from 'botbuilder-storage-redis'
const RedisDbStorage = require('botbuilder-storage-redis')
Default export is not provided; must use named import. CommonJS require works with destructuring: const { RedisDbStorage } = require('botbuilder-storage-redis').
default
import { RedisDbStorage } from 'botbuilder-storage-redis'
import RedisDbStorage from 'botbuilder-storage-redis'
There is no default export. Only named export RedisDbStorage exists.
require style (CJS)
const { RedisDbStorage } = require('botbuilder-storage-redis')
const RedisDbStorage = require('botbuilder-storage-redis')
CommonJS require must destructure the named export. Direct assignment gives undefined.

Creates a Redis client with optional prefix and TTL, then configures a BotFramework bot to use it for state storage.

import redis from 'redis'; import { RedisDbStorage } from 'botbuilder-storage-redis'; import * as builder from 'botbuilder'; const redisOptions = { prefix: 'bot-storage:' }; const redisClient = redis.createClient(process.env.REDIS_URL || 'redis://localhost:6379', redisOptions); const ttlInSeconds = 10; const storage = new RedisDbStorage(redisClient, ttlInSeconds); const connector = new builder.ChatConnector(); const bot = new builder.UniversalBot(connector); bot.set('storage', storage); console.log('Bot configured with Redis storage');
Debug
Known issues
gotchaTTL does not refresh on subsequent interactions; conversations expire after initial TTL regardless of activity.
fix
Either disable TTL (omit the second argument) or implement custom logic to extend TTL on each interaction.
affects: >=1.0.0
deprecatedThis package uses the older `redis` npm library (v2.x/v3.x) and may not be compatible with `redis` v4+ API changes.
fix
Use `redis` v3.x explicitly, or adapt to v4+ by using an adapter. Check `redis` migration guide.
affects: >=1.0.0
gotchaThe package does not support the newer `botbuilder` dialogs and adaptive dialog patterns; only classic `UniversalBot`.
fix
For new bots, consider using `botbuilder-azure` or custom storage adapter with `botbuilder-dialogs`.
affects: >=1.0.0
gotchaRedis client must be connected before creating `RedisDbStorage`; no built-in reconnection handling.
fix
Attach event listeners to `redisClient` for 'error' and 'ready' and manage connection lifecycle externally.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: redisClient.setex is not a function
Using `redis` v4+ which changed command API from callbacks to promises and renamed methods.
fix
Downgrade to `npm install redis@3.1.2` or compatible version that uses callback-based API.
Cannot destructure property 'RedisDbStorage' of ... as it is undefined
Attempting to require the package without destructuring the named export.
fix
Use: const { RedisDbStorage } = require('botbuilder-storage-redis');
Unhandled rejection: ReplyError: WRONGTYPE Operation against a key holding the wrong kind of value
Incorrect prefix or key collision with existing Redis keys of different types.
fix
Set a unique `prefix` in redisOptions to avoid clashes, or clear conflicting keys.
Upgrade
Version history
1.1.2latest on npm
Audit
Dependencies
redisrequiredRequired to create a Redis client instance passed to RedisDbStorage.
Agent activity
39 hits · last 30 days
node
34
Resources
botbuilder-storage-redis — npm install botbuilder-storage-redis · libregistry