JAVASCRIPT SDK
Events
Connect support activity to your product without coupling your app to widget internals.
Subscribe and unsubscribe
Every event has type and timestamp. Register early with the bootstrap or q queue to observe startup events. Callbacks are isolated; one failing listener does not stop other subscribers.
JavaScript
const unsubscribe = TruComWidget.on('message.received', event => {
console.log(event.conversationId, event.messageId);
});
// When your component unmounts:
unsubscribe();Event reference
| Event | Payload and timing |
|---|---|
| ready | The iframe and host handshake has completed. Public state fields are included. |
| open / close | The panel changes open state. Includes state. Closing does not end a conversation. |
| navigation.changed | The view changes; includes view. |
| conversation.started | The first message creates a visitor conversation; includes conversationId. |
| conversation.ended | The server confirms an end, including an end observed during reconciliation; includes conversationId. |
| message.sent | A message is accepted by the server; includes conversationId and messageId. Queued UI drafts are not reported as sent. |
| message.received | A new support reply is rendered; includes conversationId, messageId and senderType. Existing history is not replayed. |
| human.requested | A server-confirmed request for the team; includes conversationId. |
| unread.changed | The unread counter changes; includes count. |
| identity.changed | The visitor identity is identified or reset; includes verified. |
| attributes.changed | Website context was updated. Values are not included in the event. |
| availability.changed | Human availability changes; includes available. |
| error | A command, extension or listener fails; includes code, message and sometimes method. |
| destroyed | The installation was removed from this page. |
Handle errors
Use the rejected promise for an operation’s result. The error event is useful for centralized diagnostics; do not retry sends blindly after a timeout. The server may have accepted an in-flight request.
JavaScript
TruComWidget.on('error', event => {
console.warn(event.code, event.message);
});Analytics payloads
SDK activity events omit message text, emails, phone numbers and identity proofs. Message IDs and conversation IDs identify events, not authorization. Website code already has access to the customer data it supplies.