WIDGET API
Access to API
After the button is uploaded, the callback feature is called$owidgetOnLoad
. You can call the API feature using theowidget
object.
Api feature
init
init
Syntax
owidget.init(companyId, [widgetPreset], [language], [scope]);
Parameters
companyId
GUID identifying the company.widgetPreset
Widget name. If the parameter is missing, the default widget is used.language
Widget 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 samescope
parameter.
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
connectToServer
It uploads the configuration from the server and starts tracking the status of the operator groups.
Syntax
owidget.connectToServer();
setAppEventCallback
setAppEventCallback
Sets the callback feature to track defined events.
Syntax
owidget.setAppEventCallback(callback);
Parameters
callback
Callback function:function (e) {}
. The feature will be called each time one of the defined events occurs. The feature parameterE
will contain a structure describing an event with elements:type
Event 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
setStatusUpdateCallback
Sets the callback feature to monitor the status of the button.
Syntax
owidget.setStatusUpdateCallback(callback);
Parameters
callback
Callback feature:function (code) {}
. The feature will be called each time the button status changes. The parametercode
acquires 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
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 nullNormalize 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