⚡ Add this skill
One command
Add the Autoplay PostHog session replay provider skill for an existing PostHog setup.View the docs →
Agent onboarding
Fetch this skill when a customer already uses PostHog as a session replay provider and wants Autoplay live user activity.View the skill →
🎯 Step 1 — Set up PostHog in your app
Go to posthog.com and sign up or log in. Create a new project if you don’t have one. Your Project ID is the number in the URL once you’re inside the project:
Save your Project ID — you will use it in Steps 2 and 3.
Now install the PostHog JavaScript SDK:
main.ts, _app.tsx, or root layout). Replace YOUR_POSTHOG_PROJECT_API_KEY with your API key from the Tip above, and YOUR_POSTHOG_PROJECT_ID with the project ID you saved above:
posthog.get_distinct_id()). This makes PostHog’s distinct_id equal your app’s user id — so the same id reaches Autoplay as user_id — and links earlier anonymous activity to the identified person:
👋 Quick Tip: Once you add this code to your site, jump into our Discord and say hi — we will check your data is flowing and help you get fully set up!
Identity plumbing for widget-based support AI agents: make sure the same user identity flows across all three layers: PostHog
distinct_id / user_id, your chat widget session metadata, and the support AI agent backend sender identifier. If those do not match, chat replies will look like “no recent activity” because events are stored under one key and fetched with another.📝 Step 2 — Register your product with Autoplay
Now that your website is tracking clicks, we need to create a secure “mailing address” (Webhook URL) and a shared secret (X-PostHog-Secret) so that data can be safely sent to Autoplay.
The autoplay-sdk was installed on the Quickstart page. Create a Python file with the script below, replace the placeholders with your values from Step 1, and run it once:
- product_id:
YOUR_POSTHOG_PROJECT_ID - provider:
posthog - ingest_url:
https://connector.autoplay.ai/ingest/YOUR_POSTHOG_PROJECT_ID - ingest_secret:
{secret}— PostHog sends this as theX-PostHog-Secretheader - mcp_url:
https://mcp.autoplay.ai/mcp - mcp_key:
{secret}— your agent’s Bearer token
- Step 3 (PostHog webhook): use the
ingest_urlandingest_secretprinted above - Step 4 (read live activity): use the
mcp_urlandmcp_keyprinted above (mcp_keyis your Bearer token)
Re-registering your product
- A second
onboard_productwith the sameproduct_idreturns 409 until overwrite is allowed. - Pass
force=True. You must still passcontact_emailon every registration, including overwrites. - After a successful overwrite, the
ingest_secretrotates. Update PostHog (Step 3) soX-PostHog-Secretmatches the new secret.
🔗 Step 3 — Set up your PostHog webhook
Now we must tell the website tracker (Step 1) to send its data to the secure address (webhook) you just generated (Step 2). You have three choices: Option A — Automated with the SDK (recommended) Let the SDK create and verify the destination for you — no clicking around in PostHog, no pasting Hog code. Run this once with the values from Step 2: 📺 Generate your PostHog Personal API Key- Join our Discord and say hi.
- We configure the PostHog webhook for you.
- You receive a 1Password link with your
ingest_url,ingest_secret, andmcp_key.
- In PostHog, add a Webhook destination.
- Webhook URL: paste the
ingest_urlprinted by Step 2. X-PostHog-Secretheader: paste theingest_secretprinted by Step 2. Do not create a new secret.
let url := ....
PostHog webhook setup walkthrough
📡 Step 4 — See your activity land
Everything is wired up! The connector is pull-based — instead of streaming, you (or your agent) ask for a user’s recent activity the moment you need it. Let’s confirm your events are landing. Click around your app while logged in as an identified user, then fetch that user’s activity with themcp_key you saved from Step 2:
YOUR_USER_ID— the stable id you pass toposthog.identify(...).YOUR_MCP_KEY— themcp_keyprinted by Step 2.
200 with a populated actions array means your events are flowing. An empty array means the user identified but hasn’t browsed yet (activity is built from $pageview / $autocapture), or the events haven’t landed yet — click around and give it a few seconds.
This REST call returns the exact same data your agent reads — the agent just pulls it over MCP (the
get_live_user_activity tool) instead of curl. That’s the next step.🔌 Next: connect your AI support agent
Your activity is now flowing into the connector. Head back to Quickstart to choose your existing AI support agent and connect it via MCP — it then pulls a user’s live activity on demand, the moment it needs context to answer.Choose your AI support agent
Fin (Intercom), Maven, Ada, Botpress, and more — pick yours and connect via MCP.
extra field conventions used across the SDK, see Logging. Release history is on the Changelog.