Comment on page
JavaScript Widget
Embed and control the JavaScript widget
With Userdesk you can embed a JavaScript Widget on your website, and a chat bubble will appear on your website.
This widget exposes a global JavaScript object called
Userdesk
and you can execute some advanced actions.Set the current user's name, which is useful if the person is logged in to your website, and you want to see the name in the Messages section.
Userdesk.setName('John Doe')
Set the current user's email, which is useful if the person is logged in to your website, and you want to see the email in the Messages section and be able to send them emails when they are not online.
Userdesk.setEmail('[email protected]')
Userdesk.openWidget()
Userdesk.closeWidget()
Completely hides the widget from the page.
Userdesk.hideWidget()
Userdesk.showWidget()
It programmatically switches the widget to dark mode. It is useful if you have a dark mode selector on your website.
Otherwise, the widget automatically takes the color mode of the user system.
Userdesk.setDarkMode()
Userdesk.setLightMode()
Userdesk allows you to define an Escalate to Human button, via the Widget settings. It also provides a flow to ask for user details and receive an email.
But you can also define a custom callback to execute your JavaScript code when the user clicks the button.
For instance, you could close the widget, and open your own contact details form.
To define your callback use:
Userdesk.onEscalateToHuman = () => {
...your code...
}
Last modified 2mo ago