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.

What this means in practice: a user is half-way through an upgrade flow. They open the chat bubble and ask β€œhow do I finish this?” Without context, your bot has to ask which page they’re on. With Autoplay wired in, your bot already knows β€” and replies with the specific next click, not a walkthrough of the whole UI. This tutorial shows you exactly how to wire it together using Rasa 3.6 (open-source, self-hosted) and the Autoplay SDK. Everything stays on your infrastructure β€” your activity data, prompts, and LLM keys never leave it. Who this is for:
  • You already have (or are building) a Rasa-based chatbot for your product.
  • You want it to give answers that adapt to where the user is in the UI, instead of canned responses.
  • You’re comfortable with Python, Docker, and a small FastAPI service.
Tech you’ll use: Rasa 3.6 (Docker), Python 3.10+ (host), PostHog (free tier), the Autoplay event connector (hosted), and any LLM with an async Python client (OpenAI, Anthropic, Gemini, local β€” your choice). SDK primitives you’ll touch: AsyncConnectorClient, AsyncContextStore, AsyncSessionSummarizer, AsyncAgentContextWriter, agent_state_v2.SessionState, and ChatContextAssembly. Each one is a single import; the SDK handles the heavy lifting (reconnects, backpressure, summarisation, prompt assembly).

✨ Final result

User: how do I add a teammate?

Bot: Go to Settings β†’ Team β†’ Invite member, then enter their email
and pick a role.

(Generic reply β€” the bot doesn't know the user is already on the
Team page with the invite modal half-filled.)
Video walkthrough β€” Open on Loom if the player does not load.

πŸ“‹ Prerequisites

Before you start, you need:
  • A web app you can edit β€” anything that can load posthog-js. The examples use Next.js but it works with any frontend.
  • A free PostHog account β€” for click capture. You’ll need your Project API Key (starts with phc_, not phx_ β€” the personal one is rejected by posthog.init()).
  • An Autoplay product ID. If you already use PostHog, you can re-use your PostHog project id (the number after /project/ in the URL) as your product_id. The tutorial covers running onboard_product to mint the rest of the credentials.
  • Docker Desktop β€” Rasa runs in a container; this also sidesteps TensorFlow ABI issues on Apple Silicon.
  • Python 3.10+ on the host β€” for the small FastAPI bridge service.
  • An OpenAI API key (or any LLM provider with an async Python client) β€” the SDK’s AsyncSessionSummarizer just takes an async (str) -> str callable, so swap in Anthropic, Gemini, Mistral, or a local model if you prefer.
That’s all the setup. The rest of this tutorial walks through every code file step by step β€” copy-paste runnable.
Why a separate β€œbridge” service? Rasa runs in Docker and can’t import Python objects from your host. The bridge is a small FastAPI service that owns the Autoplay SDK pipeline and exposes a tiny HTTP surface (/reply/{user_id}) that Rasa’s action server calls when a user chats. This same pattern works for any cross-process chatbot β€” Botpress on-prem, LangChain services, Twilio webhooks β€” not just Rasa.

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Your web app    │──▢│ PostHog  │──▢│ Autoplay β”‚
β”‚  + posthog-js    β”‚   β”‚ autoclickβ”‚   β”‚ connectorβ”‚
β”‚  + chat widget   β”‚   β”‚ + HogQL  β”‚   β”‚  (SSE)   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β–²β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜
         β”‚                                  β”‚ SSE stream
         β”‚                                  β–Ό
         β”‚             β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β”‚             β”‚  bridge/  (autoplay-native, FastAPI)β”‚
         β”‚             β”‚                                     β”‚
         β”‚             β”‚  AsyncConnectorClient               β”‚
         β”‚             β”‚       ↓ on_actions                  β”‚
         β”‚             β”‚  AsyncAgentContextWriter            β”‚
         β”‚             β”‚       ↓ summarises every N actions  β”‚
         β”‚             β”‚  AsyncSessionSummarizer (your LLM)  β”‚
         β”‚             β”‚       ↓                             β”‚
         β”‚             β”‚  AsyncContextStore                  β”‚
         β”‚             β”‚       ↓                             β”‚
         β”‚             β”‚  agent_state_v2.SessionState (FSM)  β”‚
         β”‚             β”‚                                     β”‚
         β”‚             β”‚  GET /reply/{user_id}?query=…       β”‚
         β”‚             β”‚    β†’ build_user_prompt_block        β”‚
         β”‚             β”‚    β†’ call your LLM                  β”‚
         β”‚             β”‚    β†’ return reply                   β”‚
         β”‚             β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚                              β”‚ HTTP
         β”‚                              β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Rasa server (Docker) β†’ Rasa action server (Docker)         β”‚
β”‚                              └─▢ HTTP GET to bridge /reply  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
Four processes: your web app, a small Python bridge, Rasa, Rasa’s action server. The bridge owns every SDK primitive; Rasa stays a thin chat surface that calls the bridge over HTTP.

The tutorial

  1. Connect real-time events β€” Stream live user actions into a Rasa-aware bridge using the Autoplay SDK, expose them to Rasa over HTTP, and wire the chat widget to read them. This is what you’ll do today.
A follow-up tutorial on proactive triggers β€” where the bot starts the conversation when the user reaches a key moment, using agent_state_v2 and Autoplay’s proactive trigger registry β€” is in progress and will land separately.