WayloAIWaylo Docs
Web SDKAPI referenceClasses

WayloVoice

One single-use voice call. Safe to create on page load.

One single-use voice call. Safe to create on page load.

Constructors

Constructor

new WayloVoice(options): WayloVoice;

Throws RangeError for invalid options.

Parameters

ParameterType
optionsWayloVoiceOptions

Returns

WayloVoice

Methods

getMicrophoneLevel()

getMicrophoneLevel(): number;

The visitor's live mic level, 0 to 1; 0 unless microphone is on. Cheap to poll every frame.

Returns

number


getState()

getState(): WayloVoiceState;

The current state. A new frozen object whenever something changes.

Returns

WayloVoiceState


off()

off<E>(event, listener): void;

Removes a listener added with on().

Type Parameters

Type Parameter
E extends keyof WayloVoiceEvents

Parameters

ParameterType
eventE
listener(payload) => void

Returns

void


on()

on<E>(event, listener): () => void;

Adds a listener and returns a function that removes it.

Type Parameters

Type Parameter
E extends keyof WayloVoiceEvents

Parameters

ParameterType
eventE
listener(payload) => void

Returns

() => void


resumeAudio()

resumeAudio(): Promise<void>;

Lets the browser play the agent's audio when playback is blocked. Call it from a click.

Returns

Promise<void>


setMicrophoneDevice()

setMicrophoneDevice(deviceId): Promise<void>;

Uses this microphone, even before start(). Rejects with a mic error when it can't be opened; the call then keeps a working microphone where it can.

Parameters

ParameterType
deviceIdstring

Returns

Promise<void>


setMuted()

setMuted(muted): Promise<void>;

Mutes or unmutes the mic, even before start(). The last call wins; it resolves once the mic matches it. Unmuting can reject with a mic error.

Parameters

ParameterType
mutedboolean

Returns

Promise<void>


setSpeakerDevice()

setSpeakerDevice(deviceId): Promise<void>;

Uses this speaker, even before start(). Rejects with SPEAKER_UNAVAILABLE where unsupported.

Parameters

ParameterType
deviceIdstring

Returns

Promise<void>


setVolume()

setVolume(volume): void;

Sets the agent's volume, 0 to 1, for every audio track now and later.

Parameters

ParameterType
volumenumber

Returns

void


start()

start(options): Promise<void>;

Connects and resolves once the agent is ready. Call it from a click so audio can play.

Parameters

ParameterType
optionsSessionRequest

Returns

Promise<void>


stop()

stop(): Promise<void>;

Hangs up and releases the room, microphone and audio elements. Safe to call at any time.

Returns

Promise<void>


listDevices()

static listDevices(options?): Promise<WayloVoiceDevices>;

The microphones and speakers to offer. Asks for the microphone only with requestPermission.

Parameters

ParameterType
options?WayloVoiceListDevicesOptions

Returns

Promise<WayloVoiceDevices>

On this page