Widget API

Programmatic control over the Beacon widget.

All methods are available on window.Beacon (script tag) or via the useBeacon hook return value (React/Vue).

Beacon.boot(config)

Initialises and renders the widget. Called automatically when using data-workspace-id on the script tag.

Beacon.boot({ workspace_id: 'YOUR_WORKSPACE_ID' });
ParameterTypeRequired
workspace_idstringYes

Beacon.identify(identity)

Links the current session to a known contact.

Beacon.identify({
  name: '[name]',
  email: '[email]',
  phone: '[phone_number]',   // optional
  external_id: 'user_123'    // your internal user ID
});
FieldTypeNotes
namestringShown to agents
emailstringUsed to match existing contacts
phonestringOptional
external_idstringStrongly recommended; links sessions across devices

Beacon.open()

Opens the widget panel.

Beacon.open();

Beacon.close()

Closes the widget panel.

Beacon.close();

Beacon.shutdown()

Removes the widget from the page. Call on logout.

Beacon.shutdown();

Beacon.on(event, callback)

Subscribe to widget lifecycle events.

Beacon.on('open', () => { /* widget opened */ });
Beacon.on('close', () => { /* widget closed */ });
Beacon.on('message:received', (msg) => { console.log(msg.content); });
Beacon.on('conversation:started', () => { /* first message sent */ });
Beacon.on('handoff', () => { /* escalated to human */ });
EventFired when
openWidget panel is opened
closeWidget panel is closed
message:receivedA new message arrives
conversation:startedVisitor sends their first message
handoffRian escalates to a human agent

TypeScript types

interface BeaconIdentity {
  name?: string;
  email?: string;
  phone?: string;
  external_id?: string;
}
 
interface BeaconConfig {
  workspaceId: string;
  identity?: BeaconIdentity;
  cdnUrl?: string;  // override CDN base URL
}

On this page