in_memory, redis, and concurrent_redis lock stores.
Write your own when your backend is none of those, or subclass the Redis store
to change how it behaves.
Before you start
Put your code in a package next toagent.yml: a folder named addons/ with an
empty __init__.py file. Start rasa from the project root so the package can
be imported.
Subclass BaseLockStore
Import BaseLockStore from rasa.api.locks.v1 and subclass it. Do not subclass
LockStore. That is the storage port BaseLockStore is built on. BaseLockStore
adds the ticket ordering, so you only write storage methods.
addons/custom_lock_store.py
connect runs once at startup. Use it to open your client with the
settings from integrations.yml.
Register the class under lock_store:
integrations.yml
lock_store except type arrives in settings.params. Use
${VAR} for secrets so they stay out of the file.
Subclass the built-in Redis store
To change one behavior ofredis and keep the rest, subclass RedisLockStore
from the same package. This example logs each save at debug level, using only
the conversation ID:
addons/custom_redis_lock_store.py
integrations.yml
host, port, username, password, and the others in
lock_store) work the same way for
your subclass. The built-in names redis and concurrent_redis still refer to
the built-in classes. Use a module path only for your own class.
Versioning
The importrasa.api.locks.v1 is the version. YAML names only the class. A
later version ships with its own BaseLockStore, and your import keeps working
while v1 is supported. See
Custom integrations: Versioning.