Identify logged-in users
Once the widget script loads, a small JavaScript API is available at window.Ansadesk. Use it to tell Ansadesk who a visitor is and to open the chat panel from your own UI.
Attach an identity
Call Ansadesk.identify() when you know who the visitor is — for example, right after they log in. The name and email show up next to the conversation in your inbox, and attributes give agents extra context (plan, customer id, anything you like). It's safe to call before or after the widget finishes booting.
Ansadesk.identify({
name: "Jane Doe",
email: "[email protected]",
attributes: { plan: "pro", customerId: "c_123" }
});Attribute values can be strings, numbers, or booleans. Calling identify() again updates the visitor's profile.
Open the chat panel
Wire your own “Contact us” or “Help” button to open the widget:
document
.querySelector("#contact-btn")
.addEventListener("click", () => Ansadesk.open());Page context is automatic
You don't need to send the current page — every boot and message includes the page URL, and agents see it in the inbox (for example, “on /pricing”). That helps your team answer with the right context without asking.
The widget exchanges your public key for a short-lived token at boot and refreshes it automatically — no cookies, so identifying a visitor works on any origin. See the API overview for the underlying endpoints.