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.
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
| Event | When |
|---|---|
ready | The chat has loaded. |
open, close | The chat opens or closes. |
unread | The count of chats with something unread changes. |
message | A 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.
Related
Did this help?
Related articles
- Change the chat widget color, logo and launcherMatch the Opskeet chat widget to your brand: set the color, logo, theme, corners, launcher icon, position and footer in Settings.
- Identify signed-in users with a secure tokenShow who's chatting in the Opskeet inbox by passing a signed token from your server, so chats follow users across devices.
- Track events from your siteSend custom events from your site to Opskeet to see what visitors did before they wrote, build goals and trigger outbound messages.
- Chat widget settings: email ask, files, typing and onlineChoose what visitors see and share in the Opskeet chat: asking for email, file uploads, typing, online dot, seen marks and reply time.
- Style the chat widget with custom CSSAdd your own CSS to change the look of the Opskeet chat widget, with the classes you can style and the limits. Only the chat is affected.