Embed JavaScript API

The getchat JavaScript API provides an advanced layer of interaction and customization for those embedding the chatbot on their websites. This guide will walk you through the methods and events available in the current version (1.1.1) of the API, allowing for enhanced integration and user experience.

Methods

These methods allow for direct interactions with the chatbot window on your site:

Open Chatbot Window:

If you want to programmatically open the getchat window, use the following code:

document.dispatchEvent(new CustomEvent('getchat:open'));

Close Chatbot Window:

To programmatically close the getchat window, use:

document.dispatchEvent(new CustomEvent('getchat:close'));

Toggle Chatbot Window:

If you wish to toggle the state of the getchat window (i.e., open it if it's closed or vice versa), dispatch the following event:

document.dispatchEvent(new CustomEvent('getchat:toggle'));

Events

These events help you monitor and react to user interactions with the chatbot window:

Chatbot Window Opened:

If you want to track or react when the getchat window is opened, listen for the getchat:opened event:

document.addEventListener('getchat:opened', function() { // Your code here (e.g., analytics tracking) });

Chatbot Window Closed:

To take action or record when the getchat window is closed, listen for the getchat:closed event:

document.addEventListener('getchat:closed', function() { // Your code here (e.g., analytics tracking) });

Questions and support

For further assistance or inquiries about static sources, ask the getchat Bot or feel free to contact our support team.