Skip to main content
All callbacks receive typed dataclass instances, not raw dicts. Your IDE will autocomplete every field, and each model has a .to_text() method that returns an embedding-ready string.

Data structures at a glance

Use this map to understand which structure owns which concern: Directionality rules:
  • Session-owned routing state: SessionState.conversation_linked + SessionState.conversation_id
  • Reverse index lookup: ConversationLinkStore (conversation_id -> session_id)
  • Inbound webhook parse DTO: ConversationWebhookEvent
  • Outbound action/summary transport: ActionsPayload, SummaryPayload, SlimAction
  • Proactive decision input/output: ProactiveTriggerContext and ProactiveTriggerResult
  • Proactive choice-to-tour mapping: TriggerMessage with TourRegistry/TourDefinition
See also: Agent session states, BaseChatbotWriter, Payload schema, and Proactive triggers.

ActionsPayload

Delivered when the connector forwards a batch of UI actions from a user session.
to_text() example output:

Fields

string
required
Connector product identifier.
string | None
User session identifier. None for anonymous sessions before identity linking.
string | None
External user identifier passed at session boot. None when the session is fully anonymous.
string | None
User email if available from the identity store.
list[SlimAction]
Ordered list of UI actions in this batch. See SlimAction below.
int
Number of actions in this batch. Equals len(actions).
float
Unix timestamp (float) when the connector forwarded this batch.

ActionsPayload.merge(payloads)

Merges a non-empty list of ActionsPayload objects for the same session into one.
  • Actions are concatenated and re-indexed sequentially from 0
  • user_id / email resolved from the first non-None value across all inputs
  • forwarded_at set to the latest timestamp across all inputs
  • Raises ValueError if payloads is empty
Used internally by AsyncAgentContextWriter when debounce_ms > 0 to combine payloads that arrive within the accumulation window before calling write_actions.

SummaryPayload

Delivered when the connector’s LLM summariser produces a prose description of a session. Replaces the raw action list for context-window efficiency in RAG pipelines.
to_text() example output:

Fields

string
required
Connector product identifier.
string | None
User session identifier.
string
Prose description of what the user did during this session.
int
Number of individual actions this summary condenses.
float
Unix timestamp when the connector forwarded this summary.

SlimAction

A single UI action inside ActionsPayload.actions.

Fields

int
default:"0"
0-based position of this action in the session sequence.
string
default:"\"\""
Lowercase event type. One of "pageview", "click", "submit", "type", "focus", "blur".
string
Human-readable label for the event (e.g. "Page Load: Dashboard" or "Click Export CSV button").
string
Natural-language description of what the user did (e.g. "User landed on the dashboard page").
float
default:"0.0"
Unix timestamp when this action began.
float
default:"0.0"
Unix timestamp when this action ended (equals the next action’s timestamp_start). For the last action in a batch this equals timestamp_start.
string
default:"\"\""
Original URL as captured, before canonicalization (includes query strings and fragments).
string
Normalised page URL with dynamic path segments collapsed to :id (e.g. https://app.example.com/projects/:id).
string | None
PostHog session id for this action. None when unknown (same semantics as batch-level session_id).
string | None
Distinct id or identified user id for this action. None when anonymous.
string | None
User email from PostHog identity properties when present.

Using .to_text() for embeddings

Both payload types expose .to_text() so you can embed either without branching: