Control the chat with JavaScript

Open, close and hide the Opskeet chat from your own buttons and code, open help articles, switch language and listen to chat events.

Updated
On this page

The widget adds an Opskeet object to your page. Use it to open the chat from your own buttons, react to new messages, or hide the launcher.

Open the chat from a button

Add data-opskeet-open to any element. A value is written into the message box for the visitor, not sent.

<button data-opskeet-open>Chat with us</button>
<button data-opskeet-open="I'd like a demo">Book a demo</button>

To use only your own buttons, turn off Show the launcher in Settings → Chat widget → Look. The chat still opens from buttons and code.

Methods

Opskeet.open({ message }) // message is optional: written in, not sent
Opskeet.close()
Opskeet.toggle()
Opskeet.hide() // hides the launcher
Opskeet.show()
Opskeet.openArticle("getting-started") // a help article, by its address
Opskeet.searchHelp("refunds")
Opskeet.setLanguage("fr") // one of your project's languages
Opskeet.track("upgraded", { plan: "pro" })

To identify users (identify, update, logout), see Identify signed-in users. For track, see Track events from your site.

Events

const stop = Opskeet.on("unread", (count) => {})
stop() // stop listening
EventWhen
readyThe chat has loaded.
open, closeThe chat opens or closes.
unreadThe count of chats with something unread changes.
messageA new message from your team or the AI arrives: { conversationId, author, ai }.

Call it before the script loads

Add this line first, then call methods by name:

window.Opskeet =
  window.Opskeet ||
  function () {
    ;(Opskeet.q = Opskeet.q || []).push(arguments)
  }
Opskeet("open")

Hide the chat on some pages

Load the script on every page, even where you don't want the chat, and call Opskeet.hide() there. Pages without the script are missing from analytics and can't show new replies.

Did this help?

Related articles