Widget SDK reference

Control the hosted chat widget from your website.

The hosted SDK adds a launcher to your site and opens the chat window when a visitor needs it. Start with the install code from Workspace settings. This page covers the calls most sites need.

Initialize the widget

<script src="https://snoot.support/widget/snoot.js"></script>
<script>
  Snoot.init({ org: 'YOUR_WORKSPACE_ID' });
</script>

Use the generated code when possible. org accepts your workspace ID or slug. Initialization loads the launcher configuration; the chat iframe and live connections wait until a visitor opens chat.

Widget methods

Snoot.init(options)
Load the workspace settings and show the launcher.
Snoot.open() / close() / toggle()
Open, close, or toggle the chat window.
Snoot.sendMessage(message)
Open chat and send a message.
Snoot.setIdentity(token)
Adopt a short-lived, server-signed customer identity.
Snoot.setMetadata(data)
Attach customer context to future messages.
Snoot.track(event, data)
Add a custom event to conversation context and Nudge targeting.
Snoot.updatePage()
Refresh page context after client-side navigation.
Snoot.configure(options)
Update supported runtime options without rebuilding the widget.
Snoot.destroy()
Remove the launcher, chat window, and event listeners.

Listen for widget events

let handleOpen = () => console.log('Chat opened');

Snoot.on('open', handleOpen);
Snoot.on('close', () => console.log('Chat closed'));
Snoot.on('ready', () => console.log('Chat is ready'));

Snoot.off('open', handleOpen);

Snoot emits open, close, ready, and message. The ready event fires after the chat window connects, not when the launcher first loads.

Create customer identity tokens on your server. Never put your workspace identity secret in browser code.

Need help with setup? Start with the getting started guide.