Skip to content
TruCom Developers
JavaScript SDK
DocumentationWidget SDK
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

EventPayload and timing
readyThe iframe and host handshake has completed. Public state fields are included.
open / closeThe panel changes open state. Includes state. Closing does not end a conversation.
navigation.changedThe view changes; includes view.
conversation.startedThe first message creates a visitor conversation; includes conversationId.
conversation.endedThe server confirms an end, including an end observed during reconciliation; includes conversationId.
message.sentA message is accepted by the server; includes conversationId and messageId. Queued UI drafts are not reported as sent.
message.receivedA new support reply is rendered; includes conversationId, messageId and senderType. Existing history is not replayed.
human.requestedA server-confirmed request for the team; includes conversationId.
unread.changedThe unread counter changes; includes count.
identity.changedThe visitor identity is identified or reset; includes verified.
attributes.changedWebsite context was updated. Values are not included in the event.
availability.changedHuman availability changes; includes available.
errorA command, extension or listener fails; includes code, message and sometimes method.
destroyedThe 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.

TruCom DevelopersSupport that belongs in your product.

Search documentation