Listen to Events

React to Beacon widget lifecycle events in your app.

Use Beacon.on() to subscribe to widget events and trigger actions in your own code.

Available events

EventFired when
openWidget panel is opened
closeWidget panel is closed
message:receivedA new message arrives from an agent or Rian
conversation:startedThe visitor sends their first message
handoffRian escalates to a human agent

Subscribe

Beacon.on('open', () => {
  console.log('Widget opened');
});
 
Beacon.on('close', () => {
  console.log('Widget closed');
});
 
Beacon.on('message:received', (message) => {
  console.log('New message:', message.content);
});
 
Beacon.on('handoff', () => {
  console.log('Escalated to human agent');
});

Example: track widget opens in analytics

Beacon.on('open', () => {
  analytics.track('Support Widget Opened');
});

Example: show a notification badge

let unread = 0;
 
Beacon.on('message:received', () => {
  unread++;
  document.title = `(${unread}) Your App`;
});
 
Beacon.on('open', () => {
  unread = 0;
  document.title = 'Your App';
});

On this page