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 user name

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 user email

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.


Open the widget


Close the widget


Hide the widget

Completely hides the widget from the page.


Show the widget


Set dark mode

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.


Set light mode


Escalate to human callback

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

Ask questions on behalf of the user


Last updated