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

Syntax

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:

  • scope Optional parameter. On initialization, the widget will try to restore possible active conversation only if it was started in a widget initialized with the same scope parameter.

The language is determined:

  1. by owidget.init - language parameter

  2. if empty, by the language of the page (header language - F12 - Elements)

  3. if not specified, then the browser language is used

connectToServer

It uploads the configuration from the server and starts tracking the status of the operator groups.

Syntax

owidget.connectToServer();

setAppEventCallback

Sets 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

  • chatWindowOpen Chat window open.

  • chatWindowClosed Chat window closed.

  • chatSessionCreated The client waits for the operator.

  • chatSessionStarted Session with the operator began.

  • chatSessionEnded The session is over.

setStatusUpdateCallback

Sets 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

  • 0 the button is “offline”

  • 1 the button is “online”

  • 2 the button is “busy”

setCustomNumberNormalization

Sets the custom function to normalize phone number

Syntaxe

owidget.setCustomNumberNormalization(callback);

Parameters

  • callback Callback function: function (phoneNumber) { }. The function will replace the default phone number normalisation function

Expected return values

  • null If the number is in a non-invalid format, the function should return null

  • Normalize phone number If 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