Skip to Content

Client API

createVoiceAgent(config) returns a VoiceAgentClient. This is the complete method surface — the prebuilt UI and React bindings are built entirely on it.

const client = createVoiceAgent({ agentSlug: "support-bot" });

Lifecycle

client.agentSlug; // readonly — the slug this client targets await client.init(); // fetch appearance, prepare the agent → { appearance } await client.start(); // connect a call (prompts for mic permission) await client.end(); // hang up client.destroy(); // end any active call + remove all listeners
  • init() is idempotent — call it once before rendering; calling again is a no-op fetch.
  • destroy() is the required cleanup step (call it on unmount / route change).

Call controls

await client.toggleMute(); // → Promise<boolean> (new muted state) client.isActive(); // → boolean — is a call connected? client.sessionId(); // → string | null — current session id await client.sendText("hello"); // typed message to the agent (also emits a transcript line) await client.publishData(payload, "my.topic"); // low-level: publish JSON to the agent

Audio

await client.updateAudioSettings({ noiseFilter: "krisp", outputVolume: 70 }); client.getAudioState(); // → AudioStateSnapshot (prefs + applied + filter status) await client.getAudioStats(); // → AudioStats | null (loss/jitter/rtt, during a call) await client.enumerateAudioDevices(); // → { inputs, outputs } client.getAudioCapabilities(); // → { setSinkIdSupported, voiceIsolationSupported }

updateAudioSettings accepts any subset of the audio preferences and returns the resulting snapshot. Changes apply live mid-call.

Forms

client.getActiveForm(); // → { definition, values, stepIndex } | null client.updateFormValues({ email: "a@b.com" }); // push on-screen edits into the model client.stepForm("next"); // "next" | "back" | <stepIndex number> client.submitForm(); // validate → submit or advance client.closeForm(); client.openForm(definition, draft); // programmatically open a form

The core owns the form values model, validation, multi-step navigation, and the agent round-trip. Custom UIs call updateFormValues on every input. Full detail in Forms.

Appearance & language

client.getAppearance(); // → AppearanceConfig (name, theme, labels, forms, …) client.setLanguage("ne"); // change UI language client.getLanguage(); // → string

Analytics

client.trackEvent("bubble_clicked"); // "widget_loaded" | "bubble_clicked" client.trackEvent("widget_loaded", { path: location.pathname });

No-op when disableAnalytics: true is set in config.

Events

const off = client.on("transcript", (e) => { /* … */ }); off(); // unsubscribe (the return value of on()) client.off("transcript", handler); // or unsubscribe explicitly

on(name, handler) returns an unsubscribe function. Every payload is typed. See the full Events reference.

Last updated on