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]] must be replaced by your own user name. You can get your user name following the steps in this article

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

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

Toky(“onWidgetReady”, fn)

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

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

Toky(“onShow”, fn)

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

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

Toky(“onHide”, fn)

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

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

Toky(“onCallStart”, fn)

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

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

Toky(“onCallEnd”, fn)

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

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

Toky(“show”)

The method used to display the modal widget.

Toky("show");

Toky(“hide”)

The method used to hide the modal widget.

Toky("hide");

Toky(“call”)

The method used to make the widget initiate a call.

Toky("call");

Toky(“hangup”)

The method used to make the widget end a call.

Toky("hangup");

Toky(“mute”)

The method used to put the current call in mute.

Toky("mute");

Toky(“unmute”)

The method used to unmute the current call.

Toky("unmute");

Toky(“shutdown”)

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

Toky("shutdown");