Skip to main content
The BubblaV SDK provides programmatic control over your chat widget. Use it to open/close the widget, send messages, listen to events, and more.
The SDK is automatically loaded when you add the widget to your site. For React, Vue, and Angular projects, we recommend using our NPM packages for better type safety and framework integration.

Installation

For framework projects, use our official NPM packages:
1. Install the package:
2. Add the widget to your app:
3. Control the widget programmatically:
NPM packages provide full TypeScript support, framework-specific patterns, and better lifecycle management.

Global SDK

For vanilla JavaScript or when not using a framework, the SDK is available as window.BubblaV:
The SDK may not be available immediately. Use the ready() callback to ensure it’s loaded.

SDK Methods

Widget Control

open()

Opens the chat widget.
Use cases:
  • Trigger chat from a custom button
  • Open chat after a user action
  • Start conversation proactively

close()

Closes the chat widget.
Use cases:
  • Close chat after a conversation
  • Respond to user dismiss action

toggle()

Toggles the widget open/closed state.
Use cases:
  • Single button to toggle widget
  • Keyboard shortcuts for chat access

openSearch()

Opens the search interface (modal).
Use cases:
  • Trigger search from a custom button
  • Open search after a user action

isOpen()

Checks if the widget is currently open.
Returns: boolean

Messaging

sendMessage(text, conversationId?)

Sends a message programmatically.
Use cases:
  • Start conversation with a suggested message
  • Send contextual help based on page content
  • Pre-fill messages based on user actions

showGreeting(data)

Shows a greeting message to the user with optional sender information.
Use cases:
  • Display contextual greetings based on page
  • Show agent-specific messages with avatar
  • Time-based greetings (good morning, etc.)
  • Campaign-specific messages

hideGreeting()

Hides the greeting message.

Configuration

getConfig()

Gets the current widget configuration.
Returns: object with current configuration

setDebug(enabled)

Enables or disables debug mode.
Only enable debug mode in development. It logs detailed information to the console.

Event System

The SDK emits events for various widget actions. Listen to events to respond to user interactions.

on(event, callback)

Register an event listener.

off(event, callback)

Unregister an event listener.

Available Events


Framework Examples

React

Using Hooks

Using the Widget Component


Vue

Using Composition API

Using Options API


Angular


TypeScript Support

All NPM packages include full TypeScript definitions:

Best Practices

  1. Prefer NPM Packages For React, Vue, and Angular projects, use the NPM packages instead of the global SDK for better type safety and lifecycle management.
  2. Wait for Ready State Always check if the SDK is ready before using it:
  3. Clean Up Listeners Remove event listeners when they’re no longer needed:
  4. Handle Edge Cases Check if methods exist before calling:
  5. Use Environment Variables Store your website ID in environment variables:

Full SDK Reference


Next Steps

Widget Design

Customize widget appearance and behavior

Starter Templates

Quick-start templates for Next.js and Nuxt