Widget Events
The widget dispatches custom events that bubble through the DOM. Listen on the <senda-chat> element or any ancestor.
senda:message
Fired after each message exchange (user → agent).
document.querySelector('senda-chat').addEventListener('senda:message', (e) => {
console.log('User said:', e.detail.userMessage);
console.log('Agent replied:', e.detail.agentResponse);
// Example: track in analytics
analytics.track('chat_message', {
user_message: e.detail.userMessage,
agent_response_length: e.detail.agentResponse.length
});
});
Event Detail
| Field | Type | Description |
|---|---|---|
userMessage | string | The user's original message |
agentResponse | string | The agent's complete response |