Skip to main content
Autoplay streams structured UI actions from your users’ browser sessions in real time. This tutorial wires that stream to Userpilot so that when the right moment arrives — a user stuck on a page, a first-time feature visit, a repeated error — your backend detects it and fires the correct Userpilot tour immediately. This tutorial builds on How to trigger a User Tour. Complete that guide first — it covers the proxy route, EventSource connection, and payload structure. This page covers only what is specific to Userpilot.

1. Install Userpilot

Add the snippet to your app and initialize it with your token from Settings → Environments.

2. Identify the user

Call this once the user is authenticated. Use the same userId you send to PostHog so Autoplay can match sessions correctly.

3. Create a tour in Userpilot

  1. In the Userpilot dashboard go to Flows → Create flow and build your tour.
  2. Set any targeting rules you need (page URL, user segment, etc.).
  3. Publish the tour.
  4. Note the Flow ID shown in the URL bar (/flows/<flow_id>/edit).
Userpilot Flows list
Userpilot Create New Flow dialog

4. Trigger the tour

In your onmessage handler from step 3 of the manual path, add the Userpilot trigger call:
The flow_id in the payload maps to the Flow ID of your Userpilot tour, visible in the URL when editing the tour in the Userpilot dashboard.