Skip to main content

Before you start

Start the Convo AI agent or TEN graph on your backend, then return this runtime configuration to the app: Use a different Agora UID for the client, conversational agent, and avatar publisher. Never send the Spatius API Key or Agora App Certificate to the app. This path does not use a Spatius Session Token.

Connect the client

Install AvatarKit, the Web RTC Adapter, and Agora’s Web SDK:
Configure the AvatarKit WebAssembly assets for Vite or Next.js, then connect:
Call the connect flow from a user action so the browser can request microphone permission.The default connect() path lets AgoraProvider create and own the Agora client. If your app already owns one, attach the player to it before joining the channel instead. The client must use the H.264 codec. The two paths are mutually exclusive.
Your app keeps owning the client: it joins and leaves the channel, subscribes to remote tracks, and plays remote audio. detach() hands it back without leaving the channel. attach() turns on two Agora Web SDK parameters, ENABLE_VIDEO_SEI and ENABLE_FULL_LINK_AV_SYNC, which the avatar needs. They are set on the AgoraRTC module, so they apply to every Agora client on the page, and detach() does not turn them off.
Web RTC Adapter Reference
The packaged AgoraProvider coordinates audio and motion data. On the default connect path, it also owns the RTC lifecycle. Do not also call Backend Mode feed methods.

Show when the Avatar is speaking

AvatarPlayer reports whether the Avatar is idle or speaking on screen. Use it to drive speaking indicators and idle UI. The state turns to speaking on the first rendered frame of a response and returns to idle once the transition back to idle has finished playing, or when the stream stalls or the player disconnects or detaches. The event fires once per change, never per frame, and the current value is always readable from the player. AvatarKit’s own conversation state callback does not fire in RTC mode, so read the state from AvatarPlayer instead.

Next steps

Scenario demo

Integration demo

Client lifecycle