RTVI implementations will often publish helper libraries that extend the core
client with additional methods and events. For more on helpers, see
here.
Starting and stopping a session
start()
Start a session. This method sends a web request tobaseUrl
and initializes your transport class.
Calling
start()
asynchronously will resolve when the bot and client signal
that they are ready. See messages and events. If you want to
call start()
without await
, you can use the onBotReady
callback or
BotReady
event to know when you can interact with the bot.Attempting to call
start()
when the transport is not in a ready state will
throw an error.disconnect()
Disconnects from the active session. In most implementations, the bot will exit when the client disconnects. (Note however, that this is implementation-specific. The RTVI standard does not mandate bot behavior.)Bot configuration
Methods to query and update the configuration of the bot the client is connected to. See: configuration.getBotConfig()
Returns a Promise that resolves with the bot’s current configuration.voiceClient.config
. This property is hydrated with the bot’s config after start()
is called, and after any updateConfig
request.
updateConfig()
Update the bot’s config. Passing a partial config is fine. Only the individual options that are passed to theupdateConfig()
call will be updated. You can omit any services you don’t want to make changes to. You can omit any options within a service that you don’t want to change.
Returns a Promise that resolves with the full updated configuration.
On resolve, will trigger the onConfigUpdate
callback and ConfigUpdated
event.
On reject, will trigger the onMessageError
callback and MessageError
event.
VoiceClientConfigOption[] partial object with the new configuration
Should the new config be immediately applied (interrupting the bot), or wait
until the current pipeline concludes.
config
or error-response
message.
describeConfig()
Get the available config options for the bot the client is connected to. Returns a Promise that resolve’s with the bot’s configuration description.getServiceOptionsFromConfig()
VoiceClientConfigOption | undefined
Service key / string identifier e.g.
llm
getServiceOptionValueFromConfig()
unknown | undefined
Service key / string identifier e.g.
llm
Service option to retrieve e.g.
model
setServiceOptionInConfig()
VoiceClientConfigOption[]
Service key / string identifier e.g.
llm
Service option value to update, or array of service options.
Config object to update, otherwise uses a clone of the current voice client
config.
ConfigOption
object…
ConfigOption
objects.
setConfigOptions()
VoiceClientConfigOption[]
Array of service options to update.
Config object to update, otherwise uses a clone of the current voice client
config.
setServiceOptionInConfig
multiple times.
You can pass an optional config object to update, otherwise uses a clone of the current voice client config.
Returns new instance (copy) of the client config.
Messages
Dispatches aVoiceMessage
data object to the bot.
See: messages and events.
sendMessage()
A
VoiceMessage
object containing the type of message and data object to
dispatch.Actions
Dispatches a service-specific action to the bot. See: actions.action()
Dispatch an action message to the bot. What actions a bot responds to depend on how the bot is implemented. So RTVI defines an actions protocol, but does not define any specific actions. Helper libraries will often install convenience methods that make it less verbose (and more type-safe) to call actions.The action to dispatch.Returns
Promise<VoiceMessageActionResponse>
.describeActions()
Describe the actions implemented by the bot that the client is connected to. Returns a Promise that resolves with the bot’s actions description.Devices (microphones and cameras)
initDevices()
Initialize the media device selection machinery in the web browser. This method can be called beforestart()
to test and switch between camera and microphone sources.
getAllMics()
Returns a list of available microphones in the form ofMediaDeviceInfo[]
.
getAllCams()
Returns a list of available cameras in the form ofMediaDeviceInfo[]
.
updateMic()
Switches to the microphone identified by the providedmicId
, which should map a deviceId
in the list returned from getAllMics()
.
deviceId
updateCam()
Switches to the camera identified by the providedcamId
, which should map a deviceId
in the list returned from getAllCams()
.
deviceId
enableMic()
Turn on or off (unmute or mute) the client mic input.enableCam()
Turn on or off the client cam input.Tracks (audio and video)
tracks()
Returns availableMediaStreamTrack
objects for both the client and the bot.