...
Event | Description | Notes | Data sent in object property |
---|---|---|---|
Loaded | Notifies that the library has been loaded and the configuration has been read |
| |
WidgetShown | The widget is shown | If the page is configured to show more than one widget an event is raised for each widget |
|
WidgetHidden | The widget is hidden |
| |
WidgetClicked | The widget has been clicked/activated |
“Chat” “CallbackNow” “CallbackLater” | |
ChatStarted | A chat request starts |
| |
ChatOnline | The chat is active |
| |
ChatFinished | The chat is ended |
|
Message Structure
Type:
Status | ||
---|---|---|
|
Code Block | ||
---|---|---|
| ||
{
name: "CTLiveEvent",
type: <event type>
object: <event specific data type>
} |
Example
Code Block | ||
---|---|---|
| ||
if (window.addEventListener) {
addEventListener("message", messageListener, false);
} else {
attachEvent("onmessage", messageListener);
}
function messageListener (event) {
if ( typeof event !== "undefined" ) {
if ( event !== null ) {
if (event.target.location.origin !== document.location.origin) {
//Message not for me
return;
}
if (event.data.name !== "CTLiveEvent") {
return;
}
switch(event.data.type) {
case "Loaded":
console.log("[POSTMESSAGE] Received Loaded event", event.data.object);
// do some stuff...
break;
case "WidgetShown":
console.log("[POSTMESSAGE] Received WidgetShown event", event.data.object);
// do some stuff...
break;
case "WidgetHidden":
console.log("[POSTMESSAGE] Received WidgetHidden event", event.data.object);
// do some stuff...
break;
case "WidgetClicked":
console.log("[POSTMESSAGE] Received WidgetClicked event", event.data.object);
// do some stuff...
break;
case "ChatStarted":
console.log("[POSTMESSAGE] Received ChatStarted event", event.data.object);
// do some stuff...
break;
case "ChatOnline":
console.log("[POSTMESSAGE] Received ChatOnline event", event.data.object);
// do some stuff...
break;
case "ChatFinished":
console.log("[POSTMESSAGE] Received ChatFinished event", event.data.object);
// do some stuff...
break;
}
}
}
} |