After Step 1, rawDocumentation Index
Fetch the complete documentation index at: https://developers.autoplay.ai/llms.txt
Use this file to discover all available pages before exploring further.
ActionsPayload text is enough for simple copilots. For chat surfaces, you usually want multiple signals in one place: what the user asked, what they did in the product since the last message, prior turns, and (when configured) chunks from your knowledge base.
The Autoplay SDK models this as chatbot context assembly — not the same as RAG ingestion / vector pipelines (indexing documents), which happens offline or on write.
This is the core data-linking path to keep stable:
- Live events are ingested and stored by
session_id. - On first chat turn, your app creates/assigns
conversation_idand keeps it stable for the thread. - If identity is available, optionally map session refs to
user_idviaUserSessionIndex.
user_id is captured, UserSessionIndex is the SDK helper for the extra
session -> user mapping layer (also fiddly to maintain correctly at scale).
Entry points
Useautoplay_sdk.rag_query:
assemble_rag_chat_context— pulls user message, session activity, conversation history (via yourChatMemoryProvider), and KB hits (viaKnowledgeBaseRetrieverwhen wired) into a structured assembly.format_rag_system_prompt— combines your system template with that assembly so the model sees a coherent system + user picture.
RagChatProviders, assemble_rag_chat_context, format_rag_system_prompt).
Session indexing and conversation mapping
This Step 2 guidance assumes SDK0.7.3+.
session_idkeys product activity for the current user session (the event stream bucket from Step 1).conversation_idkeys chatbot memory for one chat thread.UserSessionIndexis an optional helper for deployments that captureuser_idand need user-keyed cross-session lookup.
- On the first user message in a new thread, create or assign a
conversation_id. - Reuse that same
conversation_idfor follow-up turns in the same thread. - Continue passing the current
session_idso live activity stays aligned to that thread. - If you capture
user_id, useUserSessionIndexto add user-level cross-session correlation.
session_id and conversation_id drift out of sync, responses can look stale
or generic (right docs, wrong live activity) or pull memory from the wrong
thread. If user_id is in play, that mapping must stay consistent too.
Production wiring helpers
Use these when turning Step 2 into production chat infrastructure:compose_chat_pipeline(...)— safe default composition for context store writes, agent-context writing, and summary callback fan-out.build_copilot_app(...)— minimal FastAPI bridge when you want ready-to-serve context/reply endpoints.
How this fits the recipe
| Signal | Role |
|---|---|
| User query | The question or intent you are answering in chat right now |
| Real-time events | What the user is doing in the product; aligns with ActionsPayload from Step 1 |
| Conversation history | Prior turns so answers stay coherent across the thread |
| Knowledge base | Retrieved docs or chunks when you configure a retriever |
Relationship to proactive triggers
Context assembly answers “what should the model say when the user (or system) invokes chat?” Step 3 covers when to surface proactive messages or tours without a user message — different layer, same underlying events.Code sketch
In this sketch,conversation_id is the stable chat-thread key after the user
starts chatting, while session_id keeps live activity aligned to that thread.
Add UserSessionIndex on top when you have reliable user_id capture and need
cross-session user views.











