Landbot.Livechat

Livechat widget with a launcher and proactive messages.

This class extends Landbot.Widget. See Widget methods and properties.

Constructor

Landbot.Livechat

Landbot.Livechat(config)

Parameters:

  • config: Object

Create a Landbot Livechat widget with given config.

Methods

open

open()

Open livechat widget.

close

close()

Close livechat widget.

showProactive

showProactive(messages)

Parameters:

  • messages: Array

Show a series of proactive messages (array of Messages).

myLandbot.showProactive([
  {
    type: 'text',
    samurai: -1,
    message: 'Hi there!',
  }
]);

hideProactive

hideProactive()

Close proactive messages.

A common pattern: dismiss the proactive automatically after a few seconds.

myLandbot.onLoad(function () {
  setTimeout(function () {
    myLandbot.hideProactive();
  }, 15000);
});

Customising the launcher and proactive UI

The launcher bubble is the parent-page wrapper .LandbotLivechat (with .LandbotLivechat.is-open while the chat is visible). The proactive teaser is .LivechatProactive inside the iframe. Both are documented with the rest of the launcher classes in Styling → Widget launcher and bubble.

Because the launcher sits outside the iframe and the chat content sits inside, real launcher tweaks usually inject rules into both stylesheets. See Embedding → Injecting CSS at runtime for the two-scope pattern.

Hiding the launcher on specific pages

var landbotScope = this;
this.onLoad(function () {
  if (window.location.href.includes('/pricing')) {
    landbotScope.document.styleSheets[0].insertRule(
      '.LandbotLivechat { display: none !important }'
    );
  }
});