Skip to main content

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

FieldTypeDescription
userMessagestringThe user's original message
agentResponsestringThe agent's complete response