Skip to main content

Class: BabelconnectEmbed

A mounted embed. Use the verb groups (auth, calls, session, context, app) to drive the app, and on to receive app→host events (agent.loaded, cti.call, cti.error, …).

Properties

app

readonly app: {
setTab: (tab) => void;
setTheme: (theme) => void;
};

Route the agent to a tab, and brand the app.

setTheme merges the tokens you pass into the theme already in effect and posts the merged set, so setTheme({ mode: "dark" }) changes only the mode and the app re-themes in place — no reload, no interruption to a live call. Pass null for a token to drop it back to the deployment's value. See EmbedTheme for the token table and what happens to a value the app refuses. In legacy mode, setTheme and tabs without a legacy equivalent throw UnsupportedEmbedFeatureError. Supported named tabs are phone, messaging (chat), history, and outbound.

setTab()

setTab: (tab) => void;
Parameters
tab

string | number

Returns

void

setTheme()

setTheme: (theme) => void;
Parameters
theme

EmbedTheme

Returns

void


auth

readonly auth: {
set: (args) => void;
};

Refresh the bearer token (and optionally session/context) mid-session — e.g. ahead of expiry on a long shift. Posts auth.set immediately; the live app applies it in place without interrupting the session or any active call. Also remembers the values as current, so if the iframe later reloads and re-emits ready, the handshake hands off this refreshed token rather than the one passed to BabelconnectEmbed.mount. In legacy mode, calls LegacyAuth.set with the current payload instead; the host owns how the legacy app accepts refreshed credentials.

set()

set: (args) => void;
Parameters
args

AuthSetArgs

Returns

void


calls

readonly calls: {
dial: (number, dial) => void;
};

Click-to-dial: place a call (or dial=false to only pre-fill the dialer).

dial()

dial: (number, dial) => void;
Parameters
number

string

dial

boolean = true

Returns

void


context

readonly context: {
set: (args) => void;
};

Merge into the persisted shared context carried onto subsequent calls/SMS.

set()

set: (args) => void;
Parameters
args

Record<string, unknown>

Returns

void


session

readonly session: {
set: (args) => void;
};

Attach session correlation; a number pre-fills a new SMS.

set()

set: (args) => void;
Parameters
args

Record<string, unknown>

Returns

void

Accessors

element

Get Signature

get element(): HTMLIFrameElement

The underlying iframe (e.g. to adjust sizing).

Returns

HTMLIFrameElement


instanceId

Get Signature

get instanceId(): string

This mount's identity — EmbedOptions.instanceId when you supplied one, else the id generated at mount. The app echoes it on every event, so a host with several embeds (or several tabs) can attribute every message and every ownsMedia flag to a specific one.

Returns

string

Methods

dispose()

dispose(): void

Remove the iframe and stop listening.

Returns

void


on()

on(name, fn): () => void

Subscribe to an app→host event. Returns an unsubscribe fn.

Parameters

name

string

fn

EmbedEventHandler

Returns

Function

Returns

void


mount()

static mount(opts): BabelconnectEmbed

Mount the embed: inject the iframe and start the bridge.

Parameters

opts

EmbedOptions

Returns

BabelconnectEmbed