Fetch the conversation credentials from your backend, then hand them to EquosConversation:
import { EquosConversation, EquosEvent } from "@equos/browser-sdk";const video = document.getElementById("character-video") as HTMLVideoElement;// 1. Get credentials from your backendconst res = await fetch("/api/start-conversation", { method: "POST" });const { conversation: conv, consumerAccessToken } = await res.json();// 2. Build the client with the three fieldsconst conversation = new EquosConversation({ config: { wsUrl: conv.serverUrl, token: consumerAccessToken, agentIdentity: conv.character.livekitIdentity, },});// 3. Handle events and connectconversation.on(EquosEvent.AgentConnected, () => conversation.attach(video));conversation.on(EquosEvent.Utterance, ({ utterance }) => console.log(utterance.author, utterance.content));await conversation.connect();
Common controls:
await conversation.setMicrophoneEnabled(true); // mic onconversation.sendText("Hello!"); // send a text messageawait conversation.disconnect(); // hang upconversation.detach(video); // unbind the <video>
Next.js is the canonical full-stack pattern: your API key stays on the server (in a server action or route handler), and only the conversation payload crosses to the client.Server action — app/actions.ts:
Send a text message from the user to the character—useful for typed input, accessibility, or in EquosMode.Text conversations. Behaves like the user spoke the message.
conversation.sendText("What's the refund policy?");
Inject silent context into the conversation—information the character should know about, but that isn’t spoken by the user and doesn’t appear as a message. Great for things like:
Telling the character who the logged-in user is ("The user's name is Alex, Pro tier, signed up in 2024.")
Passing in the current page or screen the user is on
Feeding live data (cart contents, current order, sensor readings) as the conversation evolves
conversation.sendContext("The user is currently viewing the pricing page.");
Unlike sendText, sendContext does not surface as a user utterance. The character picks it up as background knowledge for its next response.