BubblaV LogoBubblaV

JS SDK Basic Usage

Once the BubblaV SDK is installed on your website, you can start using its basic methods to control the chatbot widget. The SDK provides a global object, window.BubblaV, through which you can access its functions.

Accessing the API

Always ensure the SDK is fully loaded before attempting to use its methods. You can do this by checking for the window.BubblaV object or listening for the 'bubblav:ready' event.

if (window.BubblaV) {
  // SDK is ready
  console.log('BubblaV SDK is ready!');
} else {
  window.addEventListener('bubblav:ready', () => {
    console.log('BubblaV SDK is ready!');
  });
}
Chatbot Widget Basic Usage

Controlling the Chat Widget

Here are some common methods to control the visibility and state of the chat widget:

  • window.BubblaV.openChat(): Opens the chat window.
  • window.BubblaV.closeChat(): Closes the chat window.
  • window.BubblaV.toggleChat(): Toggles the chat window's visibility (opens if closed, closes if open).
  • window.BubblaV.hideWidget(): Hides the entire widget, including the chat bubble.
  • window.BubblaV.showWidget(): Shows the widget if it was hidden.
// Open the chat
window.BubblaV.openChat();

// Close the chat
window.BubblaV.closeChat();

// Toggle chat visibility
window.BubblaV.toggleChat();

// Hide the entire widget
window.BubblaV.hideWidget();

// Show the widget
window.BubblaV.showWidget();