Listen to Events

React to Beacon widget lifecycle events in your app.

Use Beacon's callback methods to subscribe to widget events and trigger actions in your own code — analytics, custom badges, browser notifications, and more.

See Event Callbacks for the full guide with detailed examples.

Available callbacks

MethodFires when
Beacon.onShow(cb)Widget panel is opened
Beacon.onHide(cb)Widget panel is closed
Beacon.onUnreadCountChange(cb)Unread count changes (also fires immediately on registration)
Beacon.onNewMessage(cb)A new message arrives from an agent or Rian

Quick examples

Beacon.onShow(function () {
  analytics.track('Support Widget Opened');
});
 
Beacon.onHide(function () {
  analytics.track('Support Widget Closed');
});
 
Beacon.onUnreadCountChange(function (count) {
  document.getElementById('badge').textContent = count;
});
 
Beacon.onNewMessage(function (message) {
  console.log('New message:', message.content);
});

Get the current unread count

For a one-off read rather than a subscription:

var count = Beacon.getUnreadCount();

On this page