Sign inStart for free
ConvoWeb Package
IntroductionPrerequisitesInstallationProject setupQuick start
Package structureConfigurationComponentsHooksAPI integrationSocket events
OverviewReplace entire UIReplace componentsStyle with classNamesThemes & localePhone & video callingIn-call control barTranslationsFeatures
Everyday chat toolsEvent callbacksUnread badgeRich-text messagesPins, stars & datesMessage threadsMentionsCanvas & draftsNotificationsAdmin permissionsServer refusalsSession & token refresh
Host app integrationTroubleshootingFAQVersion historyBest practicesSupport & contact
Web packageBuilt-in features

Event callbacks

Hear about sends, unread changes, calls and errors in your host app.

Event callbacks

Pass these on ChatMain or Chat. Each one is optional. They report activity; they do not replace the built-in UI.

tsx
1<ChatMain2  {...chatConfig}3  onMessageSent={(event) => {4    // event: { tempId, conversationId, content, kind, threadRootId? }5    toast.success("Message sent");6  }}7  onUnreadChange={(summary) => {8    // Assign. Do not add this to a previous count.9    setBadge(summary.totalUnreadCount);10  }}11  onCallStarted={(event) => {12    // event: { callId, conversationId, mode, isGroupCall }13    analytics.track("call_started", event);14  }}15  onError={(error) => {16    // error: { message, source: "chat" | "socket" | "call", code?, conversationId? }17    console.error(error.source, error.message);18  }}19/>

When each one runs

CallbackWhen it runs
onMessageSentThis user sends a DM, group message or thread reply. Offline sends fire when they press send, not when the socket reconnects. Retries do not fire again.
onUnreadChangeThe workspace unread summary changes. Same payload as onUnreadCountChange; if you pass both, both receive it.
onCallStartedThis device joins the live call (ui status "in-call"). Ringing, and a call fully replaced with features.onPhoneCall / onVideoCall, do not fire it.
onErrorA chat action fails, the socket reports an error, or a call fails. Background mark-read failures are omitted. onSocketError still receives socket errors on its own.

See also Unread badge and Session end & token refresh (onSessionEnd).

PreviousEveryday chat toolsNextUnread badge

On this page

Event callbacksWhen each one runs
Back to top