Skip to main content

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.

Autoplay streams structured UI actions from your users’ browser sessions in real time. This tutorial wires that stream to Told 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 Told 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 Told.

1. Install Told

Add the snippet to your app and initialize it with your account token from Settings → Installation.
<script>
  (function(d,t){
    var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
    g.async=true;
    g.src='https://cdn.told.io/sdk.js';
    s.parentNode.insertBefore(g,s);
    g.onload=function(){
      window.told.init('YOUR_ACCOUNT_TOKEN');
    };
  }(document,'script'));
</script>

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.
told.identify(userId, {
  name: user.displayName,
  email: user.email,
  created_at: user.createdAt, // ISO 8601
});

3. Create a tour in Told

  1. In the Told dashboard go to Tours → New Tour and build your tour.
  2. Use the visual builder to add steps — tooltips, modals, or hotspots — and attach each step to an element on your page.
  3. Set any targeting rules you need (page URL, user segment, etc.), then publish the tour.
  4. Note the Tour ID shown in the URL bar when editing the tour (/tours/<tour_id>/edit).

4. Trigger the tour

In your onmessage handler from Step 4 of the base guide, add the Told trigger call:
events.onmessage = (event) => {
  const payload = JSON.parse(event.data);

  if (payload.type !== "usertour_trigger") return;

  const mySessionId = posthog?.get_session_id?.() ?? null;
  if (!mySessionId || payload.session_id !== mySessionId) return;

  told.startTour(payload.flow_id);
};
The flow_id in the payload maps to the Tour ID of your Told tour, visible in the URL when editing the tour in the Told dashboard.