Skip to main content

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.

CallbackArgumentsDescription
onLoadNoneTriggered when the widget script and resources finish loading.
onPayloadReceivedmessage (String)Triggered when receiving payloads from automation "Send Code" modules.
onMessagemessage (Object)Triggered on incoming chat messages. Object contains content and isAdmin properties.
onOpenNoneTriggered when the widget expands/opens.
onCloseNoneTriggered when the widget minimizes/closes.