Live Chat API

Use our powerful API to automate some of your chat activities and get the most of our service!

For example, you can get visitors info, you can set the chat widget language, or you can maximize the chat widget by just calling a Javascript function, from your website.

The Javascript code must be placed just below the chat widget code as seen on the right.





    <script type='text/javascript'>
        ... onWebChat widget code ...
    </script>
    <script type='text/javascript'>
        ... API functions goes here ...
    </script>



Set Visitors Info

You can set visitors info easily. For example, you can set the visitor's name, so that you can see your visitor's names on the 'Visitor List' on admin interface.

You can set visitor name, email, phone, and notes for each visitor of your website with the following API functions:



    onWebChat.set("name","John");
    onWebChat.set("email","john@mail.com");
    onWebChat.set("phone","1234567890");
    onWebChat.set("notes","notes for visitor ..");
                        
                        

Get Visitors Info

You can also get visitor's info (set by API, PreChat form or saved by an operator).

These functions should be called after the chat widget has been loaded, so you can call it like:
onWebChat.set("onWebChatLoaded",function(){ console.log("visitor name: " + onWebChat.get("name")); });



    onWebChat.get("name");
    onWebChat.get("email");
    onWebChat.get("phone");
    onWebChat.get("notes");

Set Widget Language

You can set the widget language, choosing from 2 languages saved on admin interface (Widget Settings):

Use l1 as parameter to use your local language or l2 to use the other language texts (for visitors from other countries)





    onWebChat.set("language","l1");




Set Widget Appearance

You can control some basic aspects of widget appearance:

Use the max parameter with value 0 to minimize the chat widget or 1 to maximize it.
For example to maximize chat widget:

If you want to hide chat widget use set function with the show parameter followed by 0 .
In the same way, use 1 to show it.





    onWebChat.set("max",1);

    onWebChat.set("show",0);




Get widget status

To get the status of onWebChat widget, just call the following function:

This will return "online" or "offline" depending on the current status.

This function should be called after the chat widget has been loaded, so you can call it like:
onWebChat.set("onWebChatLoaded",function(){ console.log("chat status: " + onWebChat.get("status")); });






    onWebChat.get("status");





Callback functions

You can execute a callback function when a particular event occurs:

onClick callback is executed when a visitor clicks on the chat widget

onMaximize callback is executed when the chat widget is maximized

onMinimized callback is executed when the chat widget is minimized

onTrigger callback is executed when a trigger is activated

onStartWriting callback is executed when a visitor starts to write

onWebChatLoaded callback is executed when the chat widget is loaded




    onWebChat.set("onClick",function(){ alert('chat widget is clicked'); });

    onWebChat.set("onMaximize",function(){ alert('chat maximized'); });

    onWebChat.set("onMinimize",function(){ alert('chat maximized'); });

    onWebChat.set("onTrigger",function(){ alert('trigger activated'); });

    onWebChat.set("onStartWriting",function(){ alert('visitor is writing'); });

    onWebChat.set("onWebChatLoaded",function(){ alert('chat widget is loaded'); });


We use cookies to ensure that we give you the best experience on our website.