# JavaScript API for the chat widget

> Open, close, show or hide the chat widget from your own buttons, identify users, sign them out on shared computers, and react to unread messages.

URL: https://office.greatwork.company/chat/features/javascript-api
Last updated: 2026-11-21

Control the widget from your own code: open it from a Help button, hide it on checkout, identify users and listen for new messages.

## What you can call

- **open** and **close** the chat window, **show** and **hide** the launcher.
- **identify** a signed-in user (id, email, name, custom details, and the verification hash), and **logout** to clear them on shared computers.
- **setAttributes** to update details mid-session.
- **startConversation** with text already in the message box, for "Ask about this product" buttons.
- Listen for **unread** (with the count), **open**, **close** and **message** events.

## Common uses

Open chat from a "Talk to us" link in your footer. Hide the launcher on your checkout page so it doesn't cover the Pay button. Show your own unread badge in your app's header. Prefill "I have a question about the Pro plan" from a button on the pricing page.

## Example: A button on every product page

An outdoor gear store adds an "Ask about this item" button under each product. Clicking it starts a conversation with "Question about: Trailhead 40L pack" already typed, so the agent knows which product it is before the visitor finishes the sentence. On the checkout page the store hides the launcher and shows it again on the order confirmation page.

## How to set it up

1. Install the widget.
2. Copy the calls you need from the JavaScript API reference in Settings > Widget > Installation.
3. Test them on the test-drive page or your staging site.

---

Office by Great Work. Questions or corrections: hello@greatwork.company
