---
updatedAt: 2025-06-12T20:21:10.000Z
agentTools:
  projectIndex: https://developer.toky.co/llms.txt
---

# Javascript Methods

Learn about the methods you can use to integrate the Toky live call widget with your own code

You can use special events from the widget so you can execute custom code when some events happen.

> 🚧 Important
>
> The value **\[\[TOKY\_USERNAME]\[TOKY\_USERNAME]]** must be replaced by your own user name. You can get your user name following the steps in [this article](https://help.toky.co/en/articles/466805-where-is-my-toky-call-link)

```javascript
(function(p) {
    var s = document.createElement('script');
    s.src = 'https://call-widget.toky.co/toky-call-widget';
    s.onload = function() {
        Toky("boot", p);

        Toky("onWidgetReady", function() {
            // Do stuff
        });

        Toky("onShow", function() {
            // Do stuff
        });
        Toky("onHide", function() {
            // Do stuff
        });
        Toky("onCallStart", function() {
            // Do stuff
        });
        Toky("onCallEnd", function() {
            // Do stuff
        });

    };

    document.head.appendChild(s);
})({
    "$username": "[[TOKY_USERNAME]]",
    "$show_option": true,
    "$option": "505",
    "$position": "left",
    "$text": "Call us for free"
})
```

## Toky(“boot”, tokyWidgetSettings)

The method used to initialize the widget. It can be executed at any time.

```javascript
Toky("boot", {
  $username: "toky"
});
```

***

## Toky(“onWidgetReady”, fn)

When the widget finishes initializing, it executes the function passed as argument.

```javascript
Toky("onWidgetReady", function() {
  // Do stuff
});
```

***

## Toky(“onShow”, fn)

When the widget is displayed, the method passed as an argument is executed.

```javascript
Toky("onShow", function() {
  // Do stuff
});
```

***

## Toky(“onHide”, fn)

When the widget is hidden, the method passed as an argument is executed.

```javascript
Toky("onHide", function() {
  // Do stuff
});
```

***

## Toky(“onCallStart”, fn)

When a call is started, the method passed as an argument is executed.

```javascript
Toky("onCallStart", function() {
  // Do stuff
});
```

***

## Toky(“onCallEnd”, fn)

When a call ends, the method passed as an argument is executed.

```javascript
Toky("onCallEnd", function() {
  // Do stuff
});
```

***

## Toky(“show”)

The method used to display the modal widget.

```javascript
Toky("show");
```

***

## Toky(“hide”)

The method used to hide the modal widget.

```javascript
Toky("hide");
```

***

## Toky(“call”)

The method used to make the widget initiate a call.

```javascript
Toky("call");
```

***

## Toky(“hangup”)

The method used to make the widget end a call.

```javascript
Toky("hangup");
```

***

## Toky(“mute”)

The method used to put the current call in mute.

```javascript
Toky("mute");
```

***

## Toky(“unmute”)

The method used to unmute the current call.

```javascript
Toky("unmute");
```

***

## Toky(“shutdown”)

Method used to turn off the widget and remove it from the DOM

```javascript
Toky("shutdown");
```