UseDocumentation Index
Fetch the complete documentation index at: https://developers.autoplay.ai/llms.txt
Use this file to discover all available pages before exploring further.
UserSessionIndex when your chat layer is keyed by user_id but product events arrive keyed by session_id.
It tracks recent session refs per user and preserves product_id so reads stay product-scoped.
This gives you a stable bridge from session-keyed live events to the right user context before the app binds chat turns to a conversation_id.
session_id scoping remains the compulsory base path. UserSessionIndex is an
optional identity layer for deployments that capture user_id.
Import
Constructor
context_store:ContextStoreorAsyncContextStoreused for per-session retrieval.lookback_seconds: max age of tracked sessions before eviction.max_sessions_per_user: hard cap of session refs retained per user.
Minimal setup
Methods
add(payload)β update the index from oneActionsPayload.add_async(payload)β async alias useful for async callback wiring.get_recent_sessions(user_id)β returns newest-firstSessionRefrows.get_email(user_id)β returns the last known email cached from payloads.get_user_activity(user_id)β joins activity by callingcontext_store.get(session_id, product_id=...)across recent sessions.reset_user(user_id)β clears session refs and cached email for the user.
Behavior guarantees
- Missing
session_idpayloads are ignored. - Missing
user_idpayloads are ignored by the index (no user linkage is created), while session-scoped event storage can still continue elsewhere in your pipeline. - Session refs are deduplicated per user and sorted by
last_seen_at(newest first). - Expired refs are evicted on read and update; memory usage stays bounded.
- Product-scoped retrieval is preserved by storing
product_idin eachSessionRef.
When identity is absent
If your session replay provider does not captureuser_id, keep the compulsory
session-scoped path (session_id -> conversation_id) as your baseline.
UserSessionIndex can be introduced later once identity capture is available.
Common pitfalls
- Identity drift between event source IDs and chat user IDs causes empty reads.
- If actions are product-scoped, always preserve
product_idwhen retrieving context.











