window.BubblaV object that allows you to control the widget and search interface programmatically, as well as listen for events.
SDK Availability
The SDK is available immediately after the script loads:Methods
BubblaV.open()
Opens the chat widget.
BubblaV.close()
Closes the chat widget.
BubblaV.toggle()
Toggles the chat widget open or closed.
BubblaV.openSearch()
Opens the search interface (modal).
BubblaV.sendMessage(text, conversationId?)
Sends a message to the chatbot on behalf of the user.
- text (string): The message content to send.
- conversationId (string, optional): The ID of the conversation to send the message to. If provided, the widget switches to this conversation. If omitted, it sends to the active conversation or starts a new one.
BubblaV.showGreeting(message?)
Shows the greeting message bubble.
Parameters:
message(optional): A custom greeting message to display. If omitted, the default greeting from your settings will be used.
BubblaV.hideGreeting()
Hides the greeting message bubble.
BubblaV.on(event, callback)
Subscribes to an event.
- event (string): The name of the event to listen for.
- callback (function): The function to call when the event occurs.
BubblaV.off(event, callback)
Unsubscribes from an event.
Events
You can listen to these events usingBubblaV.on().
| Event Name | Description | Payload |
|---|---|---|
chat:opened | Triggered when the chat widget is opened. | undefined |
chat:closed | Triggered when the chat widget is closed. | undefined |
search:opened | Triggered when the search interface is opened. | { mode: string } |
search:closed | Triggered when the search interface is closed. | { mode: string } |
message:sent | Triggered when a message is sent by the user. | { conversation_id: string, text: string } |
message:received | Triggered when a message is received from the bot/agent. | { conversation_id: string, message_id: string, text: string, fromVisitor: boolean } |
message:rated | Triggered when a specific message is rated. | { conversation_id: string, message_id: string, rating: 'up' | 'down' } |
conversation:rated | Triggered when the conversation is rated. | { conversation_id: string, rating: number } |
widget:expanded | Triggered when the widget is expanded (desktop). | undefined |
widget:collapsed | Triggered when the widget is collapsed (desktop). | undefined |
search:query | Triggered when a search query is submitted. | { query: string, source: "input" | "suggestion" } |
ready | Triggered when the widget is fully loaded. | undefined |
