Comment on page
JavaScript API Examples
This page will show you a few ways you can use the Engagement Widget's JavaScript API to go beyond what's possible with the Widget Builder in ChatHQ Portal.
While these cover common scenarios, this page is far from an exhaustive list. If you feel like we're missing something feel free to add a Feature Request in our Ideas Board at https://ideas.chathq.io
This call will hide the main Widget panel containing the list of Enagement Tools, the Floating Action Button, and all Welcome Messages
window.EngagementWidget.api.hideWidget()
This call will restore the visibility of the main Widget panel containing the list of Enagement Tools, the Floating Action Button, and Welcome Messages to the state they would be if
hideWidget()
had not been called.window.EngagementWidget.api.showWidget()
This call will make the main widget panel, containing the list of Engagement Tools, visible. It will also hide the active Welcome Message, if one is visible.
window.EngagementWidget.api.openWidget()
This call will make the main widget panel, containing the list of Engagement Tools, invisible. If there is a an Welcome Message it will be made visible. Reasons a Welcome Message may be active include:
- The Welcome Message is configured to show on page load and it hasn't been dismissed by the visitor
- The Welcome Message is configured to show on scroll, the visitor scrolled the configured percentage down the page and has not dimissed the Welcome Message
- The Welcome Message is configured to show after a specified number of seconds on the page that have elapsed and the visitor has not dimissed the Welcome Message
- The Welcome Message is configured to show when an element enters the viewport of the browser, the element is currently in view, and the visitor has not dimissed the Welcome Message
window.EngagementWidget.api.closeWidget()
This call will close the main Engagement Widget panel if it is currently open (equivalent to calling
closeWidget()
), and will open it if it is closed (equivalent to calling openWidget()).
window.EngagementWidget.api.toggleWidget()
This call will make Welcome Messages invisible, regardless of their configured triggering behaviors.
window.EngagementWidget.api.hideWelcomeMessages()
This call will make Welcome Messages visible again after a previous call to
hideWelcomeMessages()
. Note that Welcome Messages triggering (e.g: scrolling, or time on page) configuration will still determine which Welcome Message is actually diaplayedwindow.EngagementWidget.api.showWelcomeMessages()