API Reference
Control the Sela widget programmatically and listen to runtime events.
Global Object
The widget exposes a global window.Sela object that you can use to control widget state and user identity.
Methods
Sela.open()
Opens the widget programmatically.
javascript
document.getElementById('help-btn').addEventListener('click', () => {
window.Sela.open();
});Sela.close()
Closes the widget.
javascript
window.Sela.close();Sela.identify(user)
Updates the current user identity, which is useful in SPAs when a user signs in without a full page reload.
javascript
window.Sela.identify({
email: 'alice@example.com',
name: 'Alice Smith',
user_hash: '...' // Optional in secure mode
});Events
You can listen to widget events with standard browser event listeners.
sela:ready
Fired when the widget is fully loaded and ready to accept commands.
javascript
window.addEventListener('sela:ready', () => {
console.log('Sela widget is ready');
window.Sela.open();
});sela:message_received
Fired when a new message arrives from the assistant or team.
javascript
window.addEventListener('sela:message_received', (event) => {
console.log('New message:', event.detail.text);
});