Web Chat Widget Advanced Configuration and Public API

Advanced Web Chat Widget Configuration

The CRM's web chat widget includes several advanced settings that aren't available in the visual builder interface. These options require manual code modification but offer greater control over widget behavior and appearance.

Custom Open Button Icon

Replace the default message bubble icon on the chat widget's open button by adding the open-icon-url attribute to your chat widget element. Set its value to the full URL of your preferred image.

Custom Close Button Icon

Change the default close icon by including the close-icon-url

attribute with the URL of your desired image file.

Prompt Display Frequency

Control how often the chat bubble appears to returning visitors using the next-prompt-timer attribute. The default value is 86400 seconds (24 hours), meaning users won't see the prompt again for 24 hours after closing it. Set this value to 0 to make the bubble appear on every page visit.

Custom Server URL

For testing and debugging purposes, you can direct widget communications to a different server using the server-u-r-l attribute. By default, the widget communicates with the standard CRM server.

Public API Methods

The chat widget exposes several JavaScript methods for programmatic control.

openWidget()

Programmatically open the chat widget from any element, such as a custom button click event:

window.CRM.chatWidget.openWidget();

closeWidget()

Programmatically close the chat widget:

window.CRM.chatWidget.closeWidget();

isActive()

Check whether the widget is currently open or closed. Returns true if expanded, false if collapsed:

window.CRM.chatWidget.isActive();

localizeWidget()

Change widget labels after the widget has loaded by passing an object with key-value pairs:

window.CRM.chatWidget.localizeWidget({"name": "Nombre"});

Internationalization (i18n)

While the chat widget doesn't automatically detect language settings, you can customize all text labels using the i-1-8n-labels attribute with a JSON string containing your translations. Supported labels include: name, phone, email, message, required, received, sending, invalid_value, send, and powered_by.

Event Handling

LC_chatWidgetLoaded Event

This event fires when the chat widget has completely loaded on the page. You can listen for this event to perform actions once the widget is ready:

window.addEventListener('LC_chatWidgetLoaded', function(e) {
  // Your code here
}, false);