SDKsWeb SDK

Methods

Every method on the instance returned by init, plus the top-level SDK object

This page is the full reference for everything you can call. Most of it covers the NapsterCompanionApiInstance — the object that drives a live session, which init resolves to — grouped by area. At the end you'll find the top-level SDK object.

Lifecycle

MethodSignatureDescription
showAvatar() => voidShow the avatar if it's hidden.
hideAvatar() => voidHide the avatar from the screen.
avatarIsVisible() => booleanWhether the avatar is currently visible.
destroy() => voidTear down the SDK, remove DOM nodes, close the connection, and release media.
if (!instance.avatarIsVisible()) instance.showAvatar();
// ...
instance.destroy();

Always call destroy() when the widget leaves the page. See teardown.

Styling and position

MethodSignatureDescription
updateStyles(styles: StyleObject) => voidMerge new inline styles into the SDK root container.
setPosition(position: Position) => voidMove the widget to one of the position values.
clearPosition() => voidClear a programmatic position and revert to the configured/default one.
updateAvatarStyle(style: Partial<avatarStyleConfig>) => voidUpdate the avatar shape and border. Only the keys you pass change.
instance.setPosition("top-left");
instance.updateAvatarStyle({ view: "rectangle" });
instance.updateStyles({ zIndex: "2000" });

Feature control

Toggle and reconfigure features after init. feature is one of the keys of the features config object.

MethodSignatureDescription
enableFeature(feature: keyof FeatureConfig) => voidEnable a feature by name.
disableFeature(feature: keyof FeatureConfig) => voidDisable a feature by name.
updateFeatureConfig(feature: keyof FeatureConfig, config) => voidUpdate a single feature's config. Partial — only the keys you pass change.
instance.disableFeature("controls");
instance.updateFeatureConfig("disclaimer", { text: "New disclaimer text" });
instance.enableFeature("controls");

Feature names are typed as keyof FeatureConfig, so your editor autocompletes them and rejects typos. The valid keys are listed in the features config.

Screen sharing

Requires features.screenShare.enabled: true. See the screen sharing feature.

MemberSignatureDescription
startScreenShare() => Promise<void>Start sharing. Opens the browser's screen picker.
stopScreenShare() => voidStop sharing.
toggleScreenShare() => Promise<void>Toggle sharing on or off.
isScreenSharingboolean (getter)Whether sharing is currently active.
isScreenShareSupportedboolean (getter)Whether the browser supports sharing and the feature is enabled.
if (instance.isScreenShareSupported) {
  await instance.toggleScreenShare();
}

Audio control

MemberSignatureDescription
muteAudio() => voidMute the avatar's audio output.
unmuteAudio() => voidUnmute the avatar's audio output.
isAudioMutedboolean (getter)Whether the avatar's audio is muted.
setAudioVolume(volume: number) => voidSet output volume. Range 01; values outside are clamped.
getAudioVolume() => numberCurrent output volume, 01. Defaults to 1.

Microphone control

MemberSignatureDescription
muteMic() => voidMute the user's microphone.
unmuteMic() => voidUnmute the user's microphone.
isMicMutedboolean (getter)Whether the microphone is muted.

Speech control

MemberSignatureDescription
stopAvatarTalking() => voidInterrupt the avatar's current response so it stops talking.
isAvatarSpeakingboolean (getter)Whether the avatar is currently speaking.
isUserTalkingboolean (getter)Whether the user is currently talking, detected from the microphone.
// Build your own push-to-talk control
if (instance.isAvatarSpeaking) instance.stopAvatarTalking();

Session and advanced

MemberSignatureDescription
sessionIdstring | undefined (getter)The current session identifier. Set once the connection is established, undefined after it closes.
sendCommand(command: DataChannelCommand) => voidSend a typed command over the data channel. See Messaging.

sessionId

Read sessionId to correlate the live session with your backend records — for example to fetch the transcript later via Monitor sessions.

const id = instance.sessionId;

sendCommand

sendCommand takes a DataChannelCommand — the typed union documented on the Messaging page.

import { DataChannelMessageType } from "@touchcastllc/napster-companion-api";

instance.sendCommand({
  type: DataChannelMessageType.SEND_MESSAGE,
  data: { text: "Hi", role: "user", trigger_response: true },
});

SDK object

The top-level NapsterCompanionApiSdk object exposes:

MemberSignatureDescription
init(token, config?) => Promise<NapsterCompanionApiInstance>Connect and mount the widget. See Initialization.
versionstringThe SDK version string, useful for diagnostics.

Next steps

On this page