JavaScript SDK
Once the widget script is on your page, a global window.Torbie object lets you control it from your own code — open the chat, send a message, or tell Torbie who the logged-in customer is.
Methods
// Open / close / toggle the chat
Torbie.open();
Torbie.close();
Torbie.toggle();
// Jump straight to the help center
Torbie.showHelp();
// Open the chat and send a message as the visitor
Torbie.sendMessage('I need help with my order');
// End the current chat
Torbie.endChat();
// Tell Torbie who the visitor is (pre-fills their profile)
Torbie.identify({ name: 'Jane Doe', email: '[email protected]' });
Identify your logged-in users
If your site knows who the visitor is, call Torbie.identify() so conversations start with context and land against the right customer profile:
<script>
window.addEventListener('load', function () {
if (window.Torbie) {
Torbie.identify({ name: 'Jane Doe', email: '[email protected]' });
}
});
</script>
Open from your own button
<button onclick="Torbie.open()">Chat with us</button>
The widget runs in an isolated shadow DOM, so its styles never clash with your site and it loads asynchronously without blocking your page.