Recipe: Cross-session episodic memory via Dakera in Rasa custom actions
Rasa's dialogue management uses slot-filling and story-based state perfectly for within-session flows, but there's no built-in mechanism to recall facts from prior conversation sessions. This proposes Dakera (https://dakera.ai) for cross-session episodic memory via Rasa custom actions.
Problem: Rasa's Tracker maintains within-session state, but enterprise deployments need to recall past customer interactions. 'This customer called about billing last month' or 'User said they prefer email notifications' should be available in new sessions.
Proposed: DakeraMemoryAction custom action:
from rasa_sdk import Action, Tracker from rasa_sdk.executor import CollectingDispatcher from dakera import DakeraClient
_memory = DakeraClient(base_url='http://localhost:3300', api_key='demo')
class ActionRecallMemory(Action): def name(self) -> str: return 'action_recall_memory'
async def run(self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: dict) -> list:
user_id = tracker.sender_id
query = tracker.latest_message.get('text', '')
response = _memory.recall(agent_id=f'rasa-{user_id}', query=query, top_k=3)
if response and response.memories:
context = '\n'.join(f'- {m.content}' for m in response.memories)
dispatcher.utter_message(text=f'I recall from our prior conversations:\n{context}')
return []class ActionStoreMemory(Action): def name(self) -> str: return 'action_store_memory'
async def run(self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: dict) -> list:
user_id = tracker.sender_id
last_bot_event = next((e for e in reversed(tracker.events) if e.get('event') == 'bot'), None)
if last_bot_event:
_memory.store_memory(
agent_id=f'rasa-{user_id}',
content=last_bot_event.get('text', ''),
session_id=f'session-{tracker.sender_id}',
)
return []Setup: docker run -d -p 3300:3300 -e DAKERA_API_KEY=demo ghcr.io/dakera-ai/dakera:latest / pip install dakera
Happy to contribute a PR with the custom actions and domain.yml example.
Source: RasaHQ/rasa