Host-page bridge
Control the embedded player from a site or kiosk with the avatarstudio v1 postMessage protocol.
Use /s/{slug} to share a standalone player with chat and microphone controls.
To drive the player from a parent page, load /embed/{slug} in an iframe and
pass the host page's URL-encoded origin in hostOrigin.
https://studio.example/embed/{slug}?hostOrigin=https%3A%2F%2Fkiosk.exampleAdd the exact origin (scheme://host[:port]) to the publication's
allowed_origins. If the list is empty, Studio uses its configured origins.
For local development, Studio accepts localhost, 127.0.0.1, and [::1].
The player accepts a command only when event.origin matches hostOrigin
and event.source === window.parent. The host should check the Studio origin
and the iframe's window before consuming an event.
Message envelope
{
"protocol": "avatarstudio",
"version": 1,
"type": "host.startListening",
"sessionId": "{slug}",
"payload": {}
}Include requestId with host.setPresentation and host.endVisit. Copy the
request ID from each action event into its host.action-result response.
Host commands
| Type | Purpose |
|---|---|
host.configure | Set host and visit parameters. Repeating the configuration is safe. |
host.start | Compatibility command. Use host.startListening to start a voice session. |
host.startListening | Connect the session if needed and enable the microphone. |
host.stopListening | Disable the microphone. |
host.sendText | Send a message from the guest with { "text": "..." }. |
host.interrupt | Interrupt the character's speech. |
host.reset | Reset the session between guests. |
host.endVisit | End a visit using schemaVersion: 1, visitId, visitGeneration, and reason. |
host.setPresentation | Set schemaVersion: 1, the visit ID and generation, mode (interactive or attract), and motionPreference (full or reduced). |
host.setViewport | Set schemaVersion: 1, layoutRevision, width, height, and safeInsets. |
host.destroy | End the session and release resources. |
host.action-result | Report the outcome of a client tool. |
host.context | Store context in the player. To pass context to the agent, include it in host.action-result. |
See agent tools for the action request and response.
Player events
| Type | Payload |
|---|---|
ready | capabilities, the available features |
capabilitiesChanged | Updated capabilities |
state | Boolean fields connected, listening, and speaking |
transcript | role (participant or character), text, and final |
action | action, arguments, and requestId |
rendererState | status (connecting, ready, disconnected, or error), optional reason and overlay |
presentationState | Current presentation state, sent when it changes |
visitEnded | localClosed, backendClosed, and optional reason |
error | message and, for a rejected visit command, code |
Check capabilities before sending commands that need them. Values include
voice, text, transcripts, state, reset, tool-calls,
visit-lifecycle, renderer-state, and presentation-v1. The player
sends ready again after a reconnect, so repeat your configuration on each
ready event and restore the host's controls.
Visits and reconnects
For kiosks, send visitId and visitGeneration to bind a guest to the
conversation, tool outcomes, and presentation state. An old command can
return stale_visit. Other visit command errors include visit_active and
request_conflict.
With visit tracking, host.reset and host.endVisit clear the conversation
context and keep the room and renderer connected. In a standard embed,
host.reset reconnects the session.
The embedded player retries renderer connections. Use rendererState.reason
to display the cause of a failure in your host UI. To use the typed wrapper,
follow the Embed SDK quickstart and
SDK reference.