Configuration (window.civchat)
The window.civchat object is defined before the SDK script loads. It configures the initial state, contact identification, and event callbacks. See Installation for where the object goes in your page.
Properties
| Property | Type | Required | Description |
|---|---|---|---|
apiKey | String | Yes | Your application API key from Settings > Workspace Settings > API & Integrations > Setup & Integrations. |
Common Contact Attributes: The following standard attributes can be set during initialization:
| Property | Type | Description |
|---|---|---|
user_id | String | Unique contact identifier for precise tracking. Takes precedence over email-based identification. |
email | String | Contact email address. Subject to Unified Identification logic when user_id is not provided. |
first_name | String | Contact's first name. |
last_name | String | Contact's last name. |
phone_number | String | Contact's phone number. |
Custom Attributes: Any additional properties are treated as custom contact attributes. For the complete attribute list, the formatting rules, and company association, see Additional contact data.
Callbacks
| 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. |
For detailed callback implementation, see Widget callbacks.