Skip to content

Events

Subscribe to widget lifecycle events with on(event, cb). It returns an unsubscribe function.

js
const off = window.laneChat.on('open', () => {
  console.log('Support panel opened')
})

// later
off() // stop listening

Available events

EventFired when
openThe chat panel opens (open() / openChat() / toggle()).
closeThe chat panel closes (close() / toggle()).

Semantics

  • on(event, cb) returns an unsubscribe function — call it to remove the listener.
  • Callbacks currently receive no payload.
  • Listener exceptions are caught and logged; a throwing callback never breaks the widget.

Example: analytics

js
window.laneChat.on('open', () => {
  window.analytics?.track('Support Widget Opened')
})

window.laneChat.on('close', () => {
  window.analytics?.track('Support Widget Closed')
})

Deeper real-time events

on() covers the widget's own UI lifecycle. For message-level and call events (new messages, typing, button clicks, calls), subscribe to Webhooks on your backend.

Lane.Chat — AI customer support, multichannel CRM, and roleplay AI.