Widget JavaScript API
After embedding the widget, you can interact with it programmatically using the global cw object.
Available methods
cw('open')– Opens the widget panel (if using floating launcher).cw('close')– Closes the widget panel.cw('reset')– Resets the current diagnostic to the start node.cw('getSessionId')– Returns the current session ID (string).cw('getCurrentNode')– Returns the ID of the current node the customer is viewing.cw('setTheme', {primaryColor: '#ff6600'})– Dynamically changes theme colours.cw('on', event, callback)– Listen to widget events (see below).
Events
widget:opened– Fired when the widget opens.widget:closed– Fired when the widget closes.diagnostic:started– Fired when a diagnostic session begins.diagnostic:completed– Fired when the customer reaches a Solution or Result node.ticket:created– Fired when a ticket is created (via contact form).
Example event listener
cw('on', 'diagnostic:completed', function(data) {
console.log('Diagnostic finished with node:', data.nodeId);
// Send custom analytics event
});
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article