Overview
Use window.contactWidget to pass your website’s user details to the support team and control the embedded widget, chat window, and official launcher.
This reference applies to the embedded Web Widget sdk.js on desktop and mobile browsers. It does not apply to Contact Page or the hosted Mobile Widget page / WebView integration. Identity features require an SDK version that provides identify and an integration environment with identity enabled.
Keep the script generated by Installation, including its identifier, type, and autoShow configuration. Do not add a hide initialization parameter.
Quick start
Define window.ContactWidgetOnReady before loading the script generated by Installation. Run API calls inside that callback, and check the specific methods you need after the widget is ready.
<script>
window.ContactWidgetOnReady = async function () {
const widget = window.contactWidget;
if (!widget || typeof widget.identify !== 'function') return;
try {
const result = await widget.identify({
userId: 'user_123',
name: 'John Doe'
});
if (!result.ok) {
console.warn('Widget identity update was not accepted.');
}
} catch {
console.warn('Widget identity update was not accepted.');
}
};
</script>
<!-- Place the exact script generated by Installation here. -->
The sample details are fictional. Replace them with data from your own login state or user system. Do not log identity payloads or raw errors. Combine multiple integration tasks in a single ready callback so they do not overwrite one another. Put examples containing await inside an async callback.
If the SDK is already loaded
const widget = window.contactWidget;
if (widget && typeof widget.once === 'function') {
widget.once('ready', function () {
if (typeof window.contactWidget?.hideFloat === 'function') {
window.contactWidget.hideFloat();
}
});
}
once('ready', ...) supports late subscriptions: it also calls the listener when ready has already fired. If the script has not loaded yet, use ContactWidgetOnReady instead.
API at a glance
All calls below must run after ready. Detect the methods your integration uses; their presence alone does not mean initialization has finished.
| Method | Purpose | Returns |
|---|---|---|
identify(payload) |
Set, update, or clear visitor identity details. | Promise<{ ok: boolean }> |
hide() |
Hide the entire widget. | void |
show() |
Restore the widget container with the window closed. | void |
open() |
Open the chat window, restoring the container if necessary. | void |
close() |
Close the chat window and related overlays. | void |
hideFloat() |
Hide the official launcher and its entry hints. | void |
openFloat() |
Re-enable the official launcher. | void |
Identify visitors
Pass the current website user’s details to the widget. Support staff can view them in the read-only Contact section of Inbox conversation details.
const result = await window.contactWidget.identify({
userId: 'user_123',
name: 'John Doe',
email: 'john@example.com',
phone: '+1 415 555 0100',
variables: { plan: 'pro', credits: 0, verified: false }
});
if (!result.ok) {
console.warn('Widget identity update was not accepted.');
}
Parameters
Every field is optional. You can pass just userId, name, or variables.
| Field | Type | Description |
|---|---|---|
userId |
string | number | null |
A stable ID from your system. Numbers must be safe integers and are converted to strings. |
name |
string | null |
Display name. |
email |
string | null |
Display email. |
phone |
string | null |
Display phone number. |
variables |
Record<string, string | number | boolean> | null |
Business fields. Keys appear as labels. Numbers must be finite; 0 and false are displayed normally. |
Obtain large integer IDs as strings directly from your system. Converting an already imprecise JavaScript Number into a string cannot recover the original ID.
Invalid field types reject the entire call with { ok: false }, without saving any fields. Examples include an unsafe integer userId, a non-string name, or an array for variables. Individual unsupported values inside a valid variables object are discarded.
Limits
| Field | Limit |
|---|---|
userId |
128 characters |
name |
256 characters |
email |
320 characters |
phone |
64 characters |
variables |
20 entries |
| Variable key | 64 characters |
| String variable value | 1,000 characters |
| Entire identity payload | 128 KiB |
Overlong values are truncated. Only the first 20 variables are retained. If the whole payload exceeds its limit, variables are removed from the end.
Update and clear behavior
| Input | Result |
|---|---|
An omitted field or undefined |
Keep the existing value. |
| An empty string for a fixed field | Treat it as omitted; do not clear the value. |
null for name, email, or phone |
Clear that field. |
A new variables object |
Replace the entire variables object; do not merge. |
variables: {} or variables: null |
Clear business fields. |
A different, non-empty userId, including the first ID |
Start with empty identity details and keep only fields in this call. Previous name, email, phone, and variables are discarded. Chat stays unchanged. |
Send userId and that user’s details in the same call. Setting name first and then sending userId separately clears the name.
// Switch to another account and set its details together.
await window.contactWidget.identify({
userId: 'user_456',
name: 'Jane Doe'
});
// Update only the email and clear business fields.
await window.contactWidget.identify({
email: 'new@example.com',
variables: {}
});
Clear identity on logout
const result = await window.contactWidget.identify({ userId: null });
if (!result.ok) {
console.warn('Widget identity update was not accepted.');
}
userId: null clears all local identity details and requests clearing the stored server identity. Other fields in the same payload are ignored. To sign in as another user, make a separate identify call.
Local identity is cleared immediately even if server clearing fails. A failed result must not be treated as confirmation that the server identity was cleared. Logging out or switching accounts does not reset the chat; see Session boundaries.
Return value and synchronization
identify returns Promise<{ ok: boolean }>.
- Before first contact:
ok: truemeans the identity was saved locally. It does not mean a server identity record has been written. - After first contact:
ok: truemeans this server identity write or clear succeeded. It does not guarantee the final result of subsequent automatic synchronization. - Expected validation, storage, or service failures return
{ ok: false }, without showing a visitor error or blocking the host page. You may make limited retries using the current user’s details; do not repeatedly submit stale account data.
Before first contact, details are only stored in the browser. After first contact, the latest details sync automatically; another identify call is not required.
First contact means a visitor message has been accepted by the server and written into the conversation, or contact information has been successfully submitted. Opening chat, clicking Send, or seeing a local message is not enough. A successful contact-form submission still counts if a subsequent message fails.
The Contact panel may not refresh immediately. Support staff should reopen or refresh the details to see updates. Empty rows are hidden; without identity, the entire section is hidden.
Identity does not create Contacts form submissions, affect their search or export, or overwrite submitted information or staff notes. A name may fill an empty or default nickname, but does not replace a name set manually by support staff.
Control the widget
Three independent layers are involved: the whole widget container, the chat window, and the official launcher. Opening the window and enabling the launcher are different operations.
All six methods below take no arguments, return void, and can be called repeatedly. They do not clear identity, chat history, drafts, or connections. A void return does not confirm message delivery.
hide()
window.contactWidget.hide();
Hide the entire widget, including the launcher and any open window. Use open() to restore the widget and open chat again.
show()
window.contactWidget.show();
Restore the container with the window closed, including a window that was open before hide(). Preserve the launcher’s existing enabled/disabled state; this does not restore an entry hidden with hideFloat().
open()
window.contactWidget.open();
Open the chat window. If the whole widget was hidden, restore its container too. Do not change the launcher switch. Opening chat does not mean a first message has been sent successfully.
close()
window.contactWidget.close();
Close the window and related overlays. Do not undo a whole-widget hide or change the launcher switch. With autoShow=false and no restored launcher, there is still no entry point after closing.
hideFloat()
window.contactWidget.hideFloat();
Hide the official launcher and entry hints; leave an open chat window visible. Useful when your site provides its own chat button.
openFloat()
window.contactWidget.openFloat();
Re-enable the launcher without opening the window. If the whole widget is hidden, also call show() to make the launcher visible. On mobile browsers, the launcher is temporarily hidden while the window is open, and follows its switch again after closing.
Common combinations
| Call order | Result |
|---|---|
hideFloat → open → close |
Open and then close the window; the launcher remains hidden. |
hide → show |
Restore the container, keep the window closed, and preserve the launcher switch. |
hide → open |
Restore the container and open chat. |
hide → openFloat → show |
Show the launcher with the chat window closed. |
Integration examples
Run these examples after ready, with checks for the methods you use.
Show or hide by route
if (/^\/checkout(?:\/|$)/.test(window.location.pathname)) {
window.contactWidget.hide();
} else {
window.contactWidget.show();
}
For an SPA, reuse this logic in your framework’s route-change callback.
Use your own chat button
Add this button to your page first:
<button id="support-open" type="button" disabled>Contact support</button>
Then wire it up after ready:
const button = document.getElementById('support-open');
if (button) {
window.contactWidget.hideFloat();
button.disabled = false;
button.addEventListener('click', function () {
window.contactWidget.open();
});
}
Remove listeners you register when the page component unmounts. Calling hide after ready may still allow an initial visual flash; see the compatibility notes below.
Limits and security
Identity and data
- Identity is for display, not authentication. Browser-provided data can be changed. Do not use it to authorize actions, operate accounts, or retrieve orders.
identifier, Visitor ID, and External User ID are not authentication credentials. - Never pass passwords, secrets, access tokens, or session credentials. Collect only the information you need. Identity and variable values are displayed as plain text.
- Use non-empty string variable keys; avoid
__proto__,prototype, andconstructor. Do not use objects or arrays as values. - Identity persists across refreshes when local storage works normally. Persistence is not guaranteed if storage is disabled, cleared, or unavailable; a local save failure returns
ok: false. - Immediate synchronization between tabs or popups is not guaranteed. Check after a refresh or the next request. Identity is not shared across domains or browsers, and the same
userIddoes not merge chats.
Session boundaries
Logging out or switching accounts does not isolate chat history. Both A → B and A → null → B preserve the same Visitor ID, history, drafts, pending messages, and connection. They also preserve Contacts submissions, existing nicknames, staff notes, and Notes. A new user on a shared device may still see old messages.
A complete reset() is not provided. Do not use identify as a substitute for account-level conversation-history isolation.
SDK compatibility and display control
- Older SDKs or environments without identity enabled may lack methods. Inside ready, check the methods you actually need, for example
typeof window.contactWidget?.open === 'function'. A method’s presence does not mean ready has fired. - Before ready,
identifyalways returns{ ok: false }; controls such ashideFloat()andopenFloat()may have no effect. Capability checks made before ready are unreliable. When identity is disabled,identifyis removed only after ready. - No pre-load command queue or
Knocket(...)entry point is provided. Calls made before ready are not guaranteed to replay. Loading or initialization failures should not block the host page. hide()does not disable the widget, stop network requests or background work, or stop data collection. Hiding after ready may still cause an initial flash.