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' });

open()

Programmatically opens the chat window.

import { open } from 'ragged-chat-sdk';
open();

close()

Programmatically closes the chat window.

import { close } from 'ragged-chat-sdk';
close();

toggle()

Toggles the chat window between open and closed states.

import { toggle } from 'ragged-chat-sdk';
toggle();

Events

The SDK emits custom DOM events that you can listen for on the `window` object to react to chat interaction.

Event NameDescription
ragged:readyFired when the SDK is fully initialized and ready.
ragged:openFired when the chat window is opened.
ragged:closeFired when the chat window is closed.