DocsAPI Reference
API Reference
Programmatically control the Ragged chat widget using our JavaScript API. This allows you to open or close the chat based on user actions or site events.
Core Methods
init(config)
Initializes the SDK and renders the chat widget on the page.
import { init } from 'ragged-chat-sdk';
init({ subdomain: 'your-bot' });
init({ subdomain: 'your-bot' });
open()
Programmatically opens the chat window.
import { open } from 'ragged-chat-sdk';
open();
open();
close()
Programmatically closes the chat window.
import { close } from 'ragged-chat-sdk';
close();
close();
toggle()
Toggles the chat window between open and closed states.
import { toggle } from 'ragged-chat-sdk';
toggle();
toggle();
Events
The SDK emits custom DOM events that you can listen for on the `window` object to react to chat interaction.
| Event Name | Description |
|---|---|
| ragged:ready | Fired when the SDK is fully initialized and ready. |
| ragged:open | Fired when the chat window is opened. |
| ragged:close | Fired when the chat window is closed. |
Back: ConfigurationEnd of Guide