> ## 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.

# Plain skill

> Connects an existing Plain workspace to Autoplay live activity via a webhook that fires when a new support thread opens. Covers the onNewThread callback, a server route that pulls the user's recent activity over REST and writes it as a note on the thread, and matching Plain's customerId to the activity source. Use when the customer already uses Plain, Plain's Live Chat app, or asks how to give Plain (Ari) real-time Autoplay context.

# AI Support Agent — Plain

> Read `autoplay-core` first for install and credentials (`product_id`, `mcp_url`, `mcp_key`).
> This skill assumes the customer already uses Plain; do not guide them
> through adopting Plain from scratch.
>
> **Who does this: Mixed.** Creating the Live Chat app and the Machine User
> (Settings → Machine users) in the Plain dashboard is a user-only step —
> there's no API for it. The webhook handler and the widget's `onNewThread`
> callback are code you write yourself. `mcp_key` comes from your own
> `onboard_product` call, not from a user.
>
> **Stay inside this project's directory tree.** Every file this skill
> touches lives inside the current project root. Never search, list, or read
> outside it.
>
> **Wait for the real `mcp_key` before running the webhook.** Run
> `onboard_product` yourself first if it hasn't been run yet — never
> hardcode a literal `YOUR_MCP_KEY`-style placeholder in your server's env
> config.

## Scoping pattern for Plain

Plain has no native MCP support, so a server-side webhook route pulls a
user's live activity on demand over REST
(`GET /users/{product_id}/{user_id}/live-activity`) the moment a new support
thread opens, and writes the last 10 actions as a note on that thread — no
polling, no local event store. The read is keyed by `product_id` + `user_id`
only; the widget's `onNewThread` callback posts `{ customerId, threadId }` to
your route, which resolves the Plain-internal customer id via Plain's
GraphQL API before writing the note.

`customerId` must exactly equal the id your activity source identifies the
user with — set it server-side as `USER_ID` before the widget script loads,
never client-side, and never fall back to email or display name.

## Reference

* Full tutorial: [https://developers.autoplay.ai/recipes/plain-tutorial/step-1-connect-real-time-events](https://developers.autoplay.ai/recipes/plain-tutorial/step-1-connect-real-time-events)
