Assistant

The Assistant class is the main entry point of the Assistants SDK. It runs in Node.js and provides everything that you need to connect an AI agent into a Whereby room - to access in-room audio and video streams, manage in-room actions and integrate with external services of your choice.

Constructor

const assistant = new Assistant(options: AssistantOptions)

AssistantOptions

Parameter
Type
Default
Description

assistantKey

string

-

Assistant key generated from the Whereby Dashboard

Methods

Room Lifecycle

To join a room or to then subsequenty perform any in-room actions, the following methods are available.

Method
Parameters
Returns
Description

joinRoom

roomUrl: string

Connects the assistant to the specified room. In case the room can not be joined the Promise will be rejected with a room joined error code.

getRoomConnection

Returns the underlying room connection controller.

With a RoomConnectionClient object the Whereby Assistant can then perform host-level in-room actions including:

  • controlling room access for knocking participants,

  • control participant spotlighting and audio/video muting/unmuting

  • sending chat messages,

  • starting and stopping cloud recording (if enabled in the room)

  • subscribing to room state changes

For a full overview of available in-room functionality refer to the RoomConnectionClient reference pages.

Media

To obtain audio and/or media streams from the room or if you want to inject audio and/or video back in to the room from the Assistant then you can use the following media APIs to do so.

Method
Parameters
Returns
Description

startLocalMedia

Promise<{

audioSource: AudioSource | null,

videoSource: VideoSource | null

}>

Creates and starts local audio and/or video media for the assistant based on parameters and returns media objects that can be used to inject media data in to the room

stopLocalMedia

void

Stops local media for the assistant

getLocalMedia

Returns the underlying local media client controller.

getCombinedAudioSink

AudioSink | null

Returns a raw audio sink object containing all in-room audio combined on a single audio channel.

Events

Assistant extends EventEmitter . You can listen to lifecycle and state change events directly:

Event
Payload
Emitted when

ASSISTANT_JOINED_ROOM

{ roomUrl: string }

Assistant has joined the room

ASSISTANT_LEFT_ROOM

{ roomUrl: string }

Assistant has left the room

PARTICIPANT_VIDEO_TRACK_ADDED

{

participantId: string;

trackId: string;

data: VideoSink

}

A remote participant has added or changed a video track

PARTICIPANT_VIDEO_TRACK_REMOVED

{

participantId: string;

trackId: string

}

A remote participant has removed a video track

PARTICIPANT_AUDIO_TRACK_ADDED

{

participantId: string;

trackId: string;

data: AudioSink

}

A remote participant has added or changed an audio track

PARTICIPANT_AUDIO_TRACK_REMOVED

{

participantId: string;

trackId: string

}

A remote participant has removed an audio track

Last updated

Was this helpful?