ChatKit JavaScript API
The loader exposes a small runtime API:
Methods
init(config)→ void
Programmatically initializes the widget (use once per page). Only needed when you don’t use the auto‑init script tag.open()/close()→ void
Opens or closes the chatbox.active()/inactive()→ void
Shows or hides the floating launcher button. (Useful if you want a custom opener.)destroy()→ void
Completely removes the widget from the page so you can re‑initialize later.
Optional Hooks
Provide any of the following properties before initialization:
async signIn()→{ jwt, expiresAt, domain? } | null
Return short‑lived credentials for the current visitor. If you returnnull/undefined, the widget proceeds as a guest or, whenmanualSignInis enabled, shows a “Sign in” button to the user.async requestSignIn()→{ jwt, expiresAt, domain? } | null
Called when the user clicks “Sign in” inside the widget. Implement your own modal/login and resolve with credentials.on(event, payload)→ void
Receive lifecycle callbacks:on('loaded', 'widget')— the launcher is ready.on('loaded', 'chatbox')— the chatbox finished loading.on('closed')— the chatbox has been closed.
Credential shape:
jwtis a string;expiresAtcan be a UNIX timestamp (ms/s) or ISO datetime;domainis optional if you need cross‑subdomain session scoping.