⚡ Add this skill
One command
Agent onboarding
Fetch this skill when a customer already uses Ada and wants its AI support agent to consume Autoplay live user activity.View the skill →
metaFields — so every conversation is grounded in what the user is actually doing in your product.
✨ Final result
- Without real-time context
- With real-time context
📋 Prerequisites
Before starting, confirm the following:- Ada already integrated on your web app — the Ada embed script is installed, your bot handle is configured, and Ada is opening chat sessions successfully.
- PostHog or Amplitude already set up — complete the Quickstart first, with
posthog.identify(user.id)(oramplitude.setUserId(user.id)) setting a stableuser_idon login. - Your
product_idandmcp_key— printed byonboard_productin the Quickstart. autoplay-sdkinstalled —pip install autoplay-sdk- A backend you can add one route to — FastAPI is shown below, but any framework that can make an outbound HTTP call works.
How identity works — Autoplay keys a user’s live activity by the stable
user_id your activity source identifies them with — the same id you pass to posthog.identify(user.id) or amplitude.setUserId(user.id). There’s no session id in the read API: every lookup is GET /users/{product_id}/{user_id}/live-activity, scoped only by product and user.When the user opens Ada, your frontend passes that same user_id to your /context/{user_id} endpoint (Step 2 below), which fetches their live activity and returns it as metaFields.If a user is anonymous (not yet identified), your activity source still records events under an anonymous id — Autoplay will have context for that id, but it won’t be linked to a real user account until you call identify / setUserId.- PostHog
- Amplitude
How the pieces fit: your app identifies the user in PostHog/Amplitude → Autoplay stores activity under that
user_id → your frontend passes the same user_id to /context/{user_id} before opening Ada → the returned metaFields are populated with that user’s real activity.The building blocks
- Define Variables in Ada — Create the Variables your bot Processes will read. Done once in the Ada dashboard.
- Serve context to the Ada SDK — Expose a lightweight endpoint that pulls a user’s live activity from Autoplay on demand (a single REST call — no listener process, no local cache) and passes it as
metaFields. - Use Variables in your Ada Processes (Step 2 — coming soon) — Reference the injected variables in your bot’s Process conditions and responses.
🔧 Step 1 — Define Variables in Ada
When you passmetaFields to the Ada embed, those keys become Variables your bot Processes can read. Create these in your Ada dashboard under Build → Variables → + New Variable.
Variable name (= metaFields key) | Type | Description |
|---|---|---|
user_id | String | Stable id from your activity source — keys the backend lookup |
current_page | String | URL the user is on, taken from their most recent action |
recent_actions | String | User’s recent in-app actions as a numbered list |
We dropped
session_summary from this table. The live-activity endpoint already returns a bounded, recent window (the limit query param), so there’s no separate summarisation step to run or store. If you want a narrative summary for longer histories, generate it inside your own /context/{user_id} handler and add it back as a metaField — it’s optional, not required for this integration to work.🌐 Step 2 — Serve context to the Ada SDK
Your backend exposes one route:GET /context/{user_id}. It calls Autoplay’s live-activity endpoint synchronously, formats the result, and returns it. No stream to consume, no worker process, no Redis — the call happens the moment your frontend needs it.
Install dependencies
FastAPI context endpoint
Protect this endpoint in production. Validate with a session cookie or short-lived signed token tied to the logged-in user — not the raw
user_id alone, which would let any caller read any user’s context.Add the Ada embed script
Adddata-lazy to your Ada embed script. This prevents Ada from initialising until you call adaEmbed.start(), so you can fetch the user’s live activity context first and pass it in on the first open.
Open Ada with live context
📋 What the context looks like
Therecent_actions string your /context/{user_id} endpoint builds from the live-activity response (Ada reads this as a Variable):
📣 Useful Ada events to subscribe to
Wire these inonAdaEmbedLoaded for guaranteed delivery:
| Event key | When | Useful for |
|---|---|---|
ada:end_conversation | User closes or ends chat | Clear or archive session context on the backend |
ada:agent:joined | Live agent joins | Stop pushing setMetaFields updates (human agent has context) |
ada:agent:left | Live agent leaves | Resume setMetaFields updates |
ada:conversation:message | New message received | Push a fresh context snapshot via setMetaFields |
ada:minimize_chat | User minimises chat | Pause non-critical context updates |