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
NPM Packages (Recommended)
For framework projects, use our official NPM packages:- React
- Vue
- Angular
1. Install the package:2. Add the widget to your app:3. Control the widget programmatically:
Global SDK
For vanilla JavaScript or when not using a framework, the SDK is available aswindow.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.
- Trigger chat from a custom button
- Open chat after a user action
- Start conversation proactively
close()
Closes the chat widget.
- Close chat after a conversation
- Respond to user dismiss action
toggle()
Toggles the widget open/closed state.
- Single button to toggle widget
- Keyboard shortcuts for chat access
openSearch()
Opens the search interface (modal).
- Trigger search from a custom button
- Open search after a user action
isOpen()
Checks if the widget is currently open.
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.
object with current configuration
setDebug(enabled)
Enables or disables debug mode.
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
- 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.
-
Wait for Ready State
Always check if the SDK is ready before using it:
-
Clean Up Listeners
Remove event listeners when they’re no longer needed:
-
Handle Edge Cases
Check if methods exist before calling:
-
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
