> ## Documentation Index
> Fetch the complete documentation index at: https://developers.autoplay.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Step 1 — Connect real-time actions

> Ingest structured ActionsPayload streams so your onboarding agent sees what the user is doing right now.

<Info>Available now.</Info>

### What you get

Every action a user takes in your product — page views, clicks, form inputs — is captured and delivered to your agent as a structured, LLM-ready payload.

This is not raw browser telemetry. Before events reach your agent, Autoplay's pipeline processes them:

1. **Extraction** — raw DOM events are extracted and normalised into typed actions
2. **Labelling** — each action is given a human-readable description with inferred intent
3. **Grouping** — actions are collected into a session with an inferred goal
4. **Summarisation** *(optional)* — the connector can run an LLM pass to produce a compact prose summary of the full session

The result is an `ActionsPayload` that your agent can read and reason over directly.

<Warning>
  `session_id` scoping is the compulsory base in this recipe. Live events are
  always ingested and stored by session.
</Warning>

<Note>
  `user_id` can be optional in some companies depending on what their session
  replay provider captures. Your pipeline should still work with session-scoped
  activity even when user identity is absent.
</Note>

### What your onboarding agent can do at this stage

Your agent can see exactly what the user is doing right now — which page they're on, what they just clicked, and what their inferred intent is. It can respond contextually to any action without waiting for the user to describe the situation in chat.

### Limitation

Every session still looks like a first session. Your agent has no memory of what this user has done before, which workflows they've already completed, or where they typically get stuck — and without a workflow ontology it cannot compare live behaviour to an ideal journey.

### Code

```python theme={null}
from autoplay_sdk import AsyncConnectorClient, ActionsPayload

async def on_actions(payload: ActionsPayload) -> None:
    # payload.to_text() is ready to inject directly into your LLM context
    current_context = payload.to_text()

    suggestion = await your_llm(
        system="You are a product onboarding agent. Based on what the user is doing, "
               "suggest one helpful next step. Be brief.",
        user=f"## What the user is doing\n{current_context}",
    )

    if suggestion:
        await push_to_ui(payload.session_id, suggestion)


client = AsyncConnectorClient(url=CONNECTOR_URL, token=API_KEY)
client.on_actions(on_actions)
```

See [Async client](../async-client) and [Webhook receiver](../webhook-receiver) for setup details.

### Optional identity enhancement: `UserSessionIndex`

Live events arrive keyed by `session_id` first. The compulsory requirement is to
keep session-scoped activity stable and then map it to the correct
`conversation_id` once chat begins.

If your deployment captures reliable `user_id`, wire
[`UserSessionIndex`](../user-session-index) to map one user to recent
`session_id` refs so cross-session retrieval can be user-keyed too.

If `user_id` is not captured, keep operating on the session-scoped base path;
you can add user scoping later without changing the core session mapping model.

**Next:** [Step 2 — Add actions to LLM context](./step-2-add-actions-to-llm-context)
