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:
StructureLayerPrimary key / scopeWrite pathRead path
SessionStateagent_state.v2session_idSessionState transitions + on_conversation_linked(link)Delivery routing and state-machine decisions
ConversationLinkchat(session_id, conversation_id, event)Created by link_conversation(...)Transition input to SessionState and store sync
ConversationLinkStorechatconversation_id -> session_idstore.save(link) inside link_conversation(...)Webhook/reverse lookup only (not delivery hot path)
ConversationWebhookEventchat webhook parsinginbound platform payloadextract_conversation_event(...) parser outputIdentity/session resolution before linking
ActionsPayloadevent stream payloadsession batchconnector emits actions frameon_actions callbacks, context writers, embeddings
SummaryPayloadevent stream payloadsession summarysummarizer emits summary frameon_summary callbacks and retrieval context
SlimActionaction item payloadper-action within batchincluded in ActionsPayload.actionsformatting, embeddings, and downstream replay
ProactiveTriggerContextproactive trigger evaluationsession_id, product_id, optional conversation_idbuilt each proactive tick from recent payloadsinput to ProactiveTriggerRegistry.evaluate_first(...)
ProactiveTriggerResultproactive trigger outputtrigger_id + delivery fieldsreturned by matching triggerdelivery layer (body, reply_option_labels, timings)
TriggerMessageproactive trigger configstable chip id + labelconfigured in ProactiveTriggerConfig.messagesmaps user chip selection to optional tour launch
TourDefinition / TourRegistryproactive visual-guidance registryid / user_tour_idparsed from integration_config.tour_registryresolves per-tour timeout/cooldown and launch metadata
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

product_id
string
required
Connector product identifier.
session_id
string | None
User session identifier. None for anonymous sessions before identity linking.
user_id
string | None
External user identifier passed at session boot. None when the session is fully anonymous.
email
string | None
User email if available from the identity store.
actions
list[SlimAction]
Ordered list of UI actions in this batch. See SlimAction below.
count
int
Number of actions in this batch. Equals len(actions).
forwarded_at
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

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

SlimAction

A single UI action inside ActionsPayload.actions.

Fields

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