Skip to main content
Rasa maintains one active timer per conversation to track inactivity. To ensure timers persist across server restarts and work in multi-pod deployments, Rasa uses a timer store. Rasa provides built-in timer store implementations to suit different deployment scenarios and requirements.

InMemoryTimerStore (default)

  • Description InMemoryTimerStore is the default timer store and it stores timers in memory. Suitable for development and testing as timers are lost on server restart.
  • Configuration To use the InMemoryTimerStore no configuration is needed.

RedisTimerStore

Description

RedisTimerStore maintains conversation timers using Redis as a persistence layer. This is the recommended option for production deployments as it supports persistence across server restarts and works in multi-pod environments. With Redis:
  • Timers survive server restarts.
  • All pods in a horizontally-scaled deployment share the same timer state.
  • Timers that expired while the server was down are recovered and processed on startup.

Configuration

To set up the timer store with Redis the following steps are required:
  1. Add required configuration to your endpoints.yml

Fallback Timer Store

If Redis is configured but becomes unavailable, Rasa automatically falls back to the InMemoryTimerStore. Sessions continue to be managed without crashing, and a warning is logged when the fallback is activated. When Redis recovers, Rasa resumes using it and logs that the fallback has been deactivated.

Custom Timer Stores

If you need a timer store which is not available out of the box, you can implement your own. To write a custom timer store, extend SessionTimerStore from rasa.core.timer_stores.timer_store. Your constructor must accept an endpoint_config parameter:
Your custom timer store class must implement all of the following methods:
  • close: releases any resources (connections, file handles, etc.) held by the store. Must respect the following signature:
  • store_timer: persists a timer entry for a conversation. Must respect the following signature:
  • delete_timer: removes a timer entry. Must respect the following signature:
  • get_timer: retrieves the current timer for a conversation, or None if none exists. Must respect the following signature:
  • get_expired_timers: returns all timers whose scheduled_time is at or before cutoff_time. Must respect the following signature:
The base class provides two helpers that can be used by the get_expired_timers method:
  • _check_time_for_expired(cutoff_time): returns cutoff_time if set, otherwise time.time().
  • _filter_expired(timers, check_time): filters an iterable of SessionTimer objects to those with scheduled_time <= check_time.
Another built-in helper method available for use in your custom timer store is:
  • SessionTimer.create_timer(sender_id, session_id, scheduled_time, metadata): constructs a SessionTimer from the arguments passed to store_timer.

Configuration

Put the module path to your custom timer store class in endpoints.yml under the timer_store key. Any additional fields are passed through as part of the EndpointConfig and are accessible via endpoint_config.kwargs:
endpoints.yml