Widget callbacks
Widget callbacks allow you to execute custom JavaScript code in response to specific events within the Positive User widget such as when it loads, opens, closes, or receives a message.
Introduction
You define callbacks directly inside the window.civchat configuration object. These functions enable deep integration between the widget and your application, allowing you to trigger Data Layer events, handle automation payloads, or log contact interactions.
Available callbacks
Each callback is documented individually below. If you are writing your configuration block for the first time, start with the complete example.
| Callback | Arguments | Description |
|---|---|---|
onLoad | None | Triggered when the widget script and resources finish loading. |
onPayloadReceived | message (String) | Triggered when receiving payloads from automation "Send Code" modules. |
onMessage | message (Object) | Triggered on incoming chat messages. Object contains content and isAdmin properties. |
onOpen | None | Triggered when the widget expands/opens. |
onClose | None | Triggered when the widget minimizes/closes. |