Skip to main content
A tracker store saves and loads the history of each conversation. The history is the tracker: every event the conversation produced, such as user messages, agent replies, and memory changes. Mantle ships in_memory, redis, mongod, sql, and dynamo stores. Write your own when your database is none of those, or subclass a built-in to change how it behaves.

Before you start

Put your code in a package next to agent.yml: a folder named addons/ with an empty __init__.py file. Start rasa from the project root so the package can be imported.

Subclass BaseTrackerStore

Import BaseTrackerStore and DialogueStateTracker from rasa.api.tracker.v1. Implement the four methods in the table below. BaseTrackerStore provides the rest, including creating the tracker for a new conversation and the session handling around each save.
addons/custom_tracker_store.py
This example keeps trackers in a dictionary so you can run it as written. Replace the dictionary calls with your database calls. Keep the serialization as JSON: deserialise_tracker reads JSON only. The conversation id is the same value in both methods. The tracker stores it as sender_id. retrieve_tracker names that argument conversation_id. BaseTrackerStore builds retrieve_full_tracker, keys, and exists on top of the four required methods, so you do not implement them. Register the class under tracker_store:
integrations.yml

Subclass the built-in Redis store

To change one behavior of the redis store and keep the rest, subclass RedisTrackerStore. This example skips saving conversations from a test harness, so they do not fill the database. The sender IDs of those conversations start with test-.
addons/custom_redis_tracker_store.py
integrations.yml
The keys in tracker_store apply to your subclass. Keep type set to the class path, because the built-in name redis selects the built-in class.

Versioning

The import rasa.api.tracker.v1 is the version. YAML names only the class. See Custom integrations: Versioning.