- You already have (or are building) a Rasa-based support AI agent 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.
httpx GET against the Autoplay live-activity REST endpoint (no client class to import β itβs just a URL, a Bearer token, and product_id/user_id), agent_state.v2.SessionState, ChatContextAssembly, plus (in Step 2) PredicateProactiveTrigger, ProactiveTriggerRegistry, and TourRegistry. The connector is pull-based, so thereβs no connection to manage β the bridge fetches a userβs recent activity the moment it needs it, and the SDK still handles prompt assembly and FSM transitions.
β¨ Final result
- Without real-time context
- With real-time context
π 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_, notphx_β the personal one is rejected byposthog.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 yourproduct_id. The tutorial covers runningonboard_productto 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 bridge calls it directly with a plain
(str) -> strasync function, so swap in Anthropic, Gemini, Mistral, or a local model if you prefer.
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 support AI agent β Botpress on-prem, LangChain services, Twilio webhooks β not just Rasa.Architecture
The tutorial
- Step 1 β Connect real-time events β Pull a userβs live activity on demand into a Rasa-aware bridge using the Autoplay SDKβs REST read, expose it to Rasa over HTTP, and wire the chat widget. Reactive answers grounded in real activity. ~45 minutes.
-
Step 2 β Define proactive triggers β Make the bot proactive: notice when a user is on the slow path of a workflow and surface a toast with two CTAs β Show me (visual tour via Usertour) or Open chat (proactive bot message with an LLM-grounded auto-followup). Uses
PredicateProactiveTrigger,agent_state.v2.SessionState, andTourRegistry. ~45 minutes.