WIDGET API
Access to API
After the button is uploaded, the callback feature is called$owidgetOnLoad. You can call the API feature using theowidgetobject.
<script type="text/javascript">
(function () {
var scr = document.createElement('script');
scr.type = 'text/javascript';
scr.async = true;
scr.charset = 'UTF-8';
scr.src = '//app.mluvii.com/widget/OOWidget.js';
scr.$owidgetOnLoad = function (owidget) {
if (!owidget.isSupported) {
return;
}
// owidget.init(...);
// ...
// owidget.connectToServer();
};
var ffs = document.getElementsByTagName('script')[0];
ffs.parentNode.insertBefore(scr, ffs);
})();
</script>Api feature
init
initSyntax
owidget.init(companyId, [widgetPreset], [language], [scope]);
Parameters
companyIdGUID identifying the company.widgetPresetWidget name. If the parameter is missing, the default widget is used.languageWidget language. If the parameter is missing, other parameters are used, see below:scopeOptional parameter. On initialization, the widget will try to restore possible active conversation only if it was started in a widget initialized with the samescopeparameter.
The language is determined:
by owidget.init - language parameter
if empty, by the language of the page (header language - F12 - Elements)
if not specified, then the browser language is used
connectToServer
connectToServerIt uploads the configuration from the server and starts tracking the status of the operator groups.
Syntax
owidget.connectToServer();
setAppEventCallback
setAppEventCallbackSets the callback feature to track defined events.
Syntax
owidget.setAppEventCallback(callback);
Parameters
callbackCallback function:function (e) {}. The feature will be called each time one of the defined events occurs. The feature parameterEwill contain a structure describing an event with elements:typeEvent type.
Event Types
chatWindowOpenChat window open.chatWindowClosedChat window closed.chatSessionCreatedThe client waits for the operator.chatSessionStartedSession with the operator began.chatSessionEndedThe session is over.
setStatusUpdateCallback
setStatusUpdateCallbackSets the callback feature to monitor the status of the button.
Syntax
owidget.setStatusUpdateCallback(callback);
Parameters
callbackCallback feature:function (code) {}. The feature will be called each time the button status changes. The parametercodeacquires one of the three values described below.
Button status codes
0the button is “offline”1the button is “online”2the button is “busy”
setCustomNumberNormalization
setCustomNumberNormalizationSets the custom function to normalize phone number
Syntaxe
owidget.setCustomNumberNormalization(callback);
Parameters
callbackCallback function:function (phoneNumber) { }. The function will replace the default phone number normalisation function
Expected return values
nullIf the number is in a non-invalid format, the function should return nullNormalize phone numberIf the entered number is in the correct format, the string with the phone number in the international format is returned, eg even +420 777 666 555 even if the entry was only 777 666 555
Last updated
Was this helpful?