The Microsoft Bot Framework SDK provides a flexible architecture for managing bot state, structured around three core layers: the storage layer, which physically stores data; the state management layer, which handles read/write operations and caching; and state property accessors, which provide methods to interact with specific state properties. This modular design allows developers to swap out the storage layer without disrupting the rest of the bot’s logic, making it ideal for privacy-sensitive deployments.
For organizations with strict data sovereignty or compliance requirements, Redis is a highly recommended alternative to Azure Blob Storage. Redis offers high-performance, in-memory data storage with built-in Time-To-Live (TTL) support, allowing you to automatically expire state data after a defined period. The Bot Framework SDK includes a RedisStorage
class that can be configured with custom hostnames, ports, and credentials, giving you full control over where and how data is stored. This setup ensures that sensitive user data remains within your infrastructure while maintaining the reliability and scalability benefits of persistent storage.
Alternatively, for maximum flexibility, you can implement a custom storage adapter by creating a class that conforms to the Bot Framework’s IStorage
interface. This involves implementing three core methods: read
, write
, and delete
. A custom adapter allows you to integrate with any backend system—on-premises databases, encrypted local files, or even ephemeral in-memory caches—tailored to your organization’s privacy and compliance policies.
Both Redis and custom storage adapters preserve the bot’s ability to maintain state across restarts and scaling events, which is essential for production reliability. They also support advanced features like error handling, retry logic, and monitoring, ensuring robust bot behavior without compromising user privacy.
Reference Links : Implement custom storage for your bot
Hope it helps
Thank you