Skip to content
Office

Office Chat feature

JavaScript API for the chat widget

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. 1

    Install the widget.

  2. 2

    Copy the calls you need from the JavaScript API reference in Settings > Widget > Installation.

  3. 3

    Test them on the test-drive page or your staging site.

JavaScript API for the chat widget is part of Office Chat and included on every plan.

Try Office Chat with your whole team

7-day trial with every feature. Cancel from the billing page whenever you like.