Skip to content

Messaging

sendMessage(text)

Sends a text message to the avatar. The avatar generates an LLM response and replies with voice.

js
SDK.sendMessage('Hello');
ParameterTypeDescription
textstringMessage to send

speak(text)

Makes the avatar read the given text as-is (without LLM processing).

js
SDK.speak('Please read this sentence exactly');
ParameterTypeDescription
textstringText for the avatar to read

Sending messages right after stopSpeaking()

Calling speak() or sendMessage() immediately after stopSpeaking() may cause the server to drop the request. Wait for the RESPONSE_ENDED signal first.

js
let pendingText = null;

SDK.onSignal((data) => {
  if (data.signal === 'RESPONSE_ENDED' && pendingText) {
    SDK.speak(pendingText);
    pendingText = null;
  }
});

function stopAndSpeak(text) {
  pendingText = text;
  SDK.stopSpeaking();
}

sendSpeakAudio(audio)

Sends Base64-encoded audio data so the avatar lip-syncs to the audio.

js
SDK.sendSpeakAudio(base64AudioData);
ParameterTypeDescription
audiostringBase64-encoded audio data (max 0.1MB)

Data exceeding 0.1MB or invalid Base64 format will be rejected. You can call this multiple times to send audio in chunks. After sending all chunks, call endSpeakAudio().

endSpeakAudio()

Ends the audio echo transmission. Once the server receives this signal, it begins lip-sync processing with the received audio.

js
// Send in chunks then end
for (const chunk of audioChunks) {
  SDK.sendSpeakAudio(chunk);
}
SDK.endSpeakAudio();

clearMessages()

Clears the conversation message list when using <chat-container>.

js
SDK.clearMessages();