State Management
Calls in the Enterprise Bot Builder SDK can be handled in two ways.
- The notifications and events for a particular call are always received on a single application instance. This means that the instance should be maintaining the state of a call in memory and a single
Call
object exists throughout the duration of the call. These are called Stateful bots. - The notification or events for any call can hit any instance of the application. This means that everytime a notification comes to an instance, a new
Call
object is created by the SDK and is destroyed once the notification/event has been handled. Any state required for the call should be maintained by the bot logic. These are called Stateless bots signifying that the SDK itself does not maintain any state for the bot.
Differences between Stateless and Stateful bots
The major difference betweeen Stateless and Stateful bots is that maintaining Stateful bots requires that the bot instance would not go down when a call is in progress. If the instance goes down, the call object is lost and no notifications or events are received by the SDK and the calls gets dropped by the server. On the contrast, in Stateless bots, even if the bot instance goes down, the events and notifications go to the other instances of the bot and the bot can continue its logic.
Important
In Local Media Calls, the media is handled by a single instance of the bot. Therefore, all the notifications should reach the same instance of the bot for signaling of the media to be properly handled. Therefore Stateless scenarios for Local Media bots are not supported.