/*The following functions use methods to assign and get values via HTML structures to exemplify the use of such methods.
To use these features in your own environment you need to comment out or remove the HTML related code and replace it with your own data.*/
const DialResult = {
2: "Busy",
3: "Not Answer",
4: "Fax/Modem",
5: "NoDialTone",
8: "Other",
10: "NoService",
11: "VoiceMail/Machine",
12: "Circut Busy",
13: "Cancelled",
90:"Rejected by provider"
};
/********************* Session events *********************/
/**
* @description Catch successful login.
* @event onLogin
* @see login
* @tutorial DataAgent
*/
function onLogin() {
console.log("Int-CA-onLogin");
printToConsole("onLogin");
}
/**
* @description Catch the session ended with the method {@link closeSession}.
* @event onLogOut
* @see closeSession
* @tutorial DataAgent
*/
function onLogOut() {
console.log("Int-CA-onLogOut");
printToConsole("onLogOut");
}
/**
* @description Catch successful password change.
* @event onPasswordUpdated
* @see ChangePassword
* @tutorial DataAgent
*/
function onPasswordUpdated() {
console.log("Int-CA-onPasswordUpdated");
printToConsole('onPasswordUpdated');
}
/**
* @description Catch telephony status.
* @event onTelephonyStatus
* @param {string} status Telephony status
*/
function onTelephonyStatus(status) {
console.log("Int-CA-onTelephonyStatus",status);
printToConsole("onTelephonyStatus: "+status);
}
/********************* Agent Information Events *********************/
/**
* @description Catch the agent ID.
* @param {int} id Contains the id of the current agent.
* @example {data:10}
*/
function onAgentId(id) {
console.log("Int-CA-onAgentId", id);
document.getElementById("UserIDTxt").value = id;
}
/**
* @description Catch the agent extension
* @param {string} extension Contains the extension of the current agent user.
* @example {data:-1}
*/
function onExtension(extension) {
console.log("Int-CA-onExtension", extension);
document.getElementById("ExtensionTxt").value = extension;
}
/**
* @description Catch the username
* @param {string} username Contains the current agent username.
* @example {data:"daniAgent"}
*/
function onUsername(username) {
console.log("Int-CA-onUsername", username);
document.getElementById("LoginTxt").value = username;
}
/********************* Agent Status Events *********************/
/**
* @description Catch the information related to the current state of the agent.
* @event onAgentStatus
* @param {json} agentStatus Each state brings different information, but the currentState property is common for all of them and tells us the name of the current state.
* @example agentStatus = {agentData: {userExt: "-1",userId: 94,userName: "daniAgent"}, currentState: "Ready"}
* @example agentStatus = { currentState: "NotReady", description: "Break"}
* @example Agent States
* {'Assisted','Callout','Dialog','Login','Logout','NotConnected,'NotReady','Other','Problem','Ready','RECONNECT','RinginFail','Ringing','Unknown','Wrapup','WRAPUP_FAIL','Xfer','XferFail'}
*/
function onAgentStatus(agentStatus) {
console.log("Int-CA-onAgentStatus", agentStatus);
let state = agentStatus.currentState;
switch (state) {
case 'NotConnected':
setTimeout(() => {
connectToServer();
}, 1000);
break;
case 'NotReady':
state += " (id=" + agentStatus.notReadyId + "=" + agentStatus.description + ")";
break;
case 'Ready':
onAuxiliarReadyStatus('Ready');
break;
default:
break;
}
document.getElementById("status").value = state;
printToConsole("onAgentStatus --> currentState:" + agentStatus.currentState + (agentStatus.notReadyId ? ", notReadyId:" + agentStatus.notReadyId : ""));
}
/********************* Unavailable Events *********************/
/**
* @description Catch the unavailable list
* @param {Array} unavailableList Each Array is composed of a json that contains the characteristics of each not available (description, id, etc).
* @example [{Description: string, Frame: uint, Max: string, NotReadyRestricted: uint, NumberOfEvents: string/uint, TypeNotReadyId: uint}
* @example [{Description: "No Clasificado", Frame: 1, Max: "00:00:00", NotReadyRestricted: 0, NumberOfEvents: "n", TypeNotReadyId: 1},
* {Description: "Sistema3", Frame: 8, Max: "01:00:00", NotReadyRestricted: 0, NumberOfEvents: "12", TypeNotReadyId: 14}]
* @event onUnavailableTypes
*/
function onUnavailableTypes(unavailableList) {
console.log("Int-CA-onUnavailableTypes", unavailableList);
let notReadyList = document.getElementById("selectUnavailables");
notReadyList.innerHTML = "";
for (const unavailable of unavailableList) {
if (unavailable !== undefined) {
let option = document.createElement("option");
option.text = unavailable.TypeNotReadyId + "=" + unavailable.Description;
option.value = unavailable.TypeNotReadyId;
notReadyList.add(option);
}
}
}
/********************* Campaign Events *********************/
/**
* @description Catch a list of assigned campaigns.
* @event onCampaigns
* @param {Object} campaignList Contains the characteristics of each of the available campaigns.
* @example {Default:boolean, Description:string, GraphicID:uint ,ID:uint}
* @example {{Default:true, Description:"NormalDna", GraphicID:3 ,ID:3},{Default:false, Description:"PredictivaDna", GraphicID :1, ID:5}}
*/
function onCampaigns(campaignList) {
if (campaignList) {
console.log("Int-CA-onCampaigns ", campaignList);
let campaigns = document.getElementById("Campaigns");
campaigns.innerHTML = "";
for (const campaign in campaignList) {
if (campaign !== undefined) {
let option = document.createElement("option");
option.text = campaignList[campaign].Description;
option.value = campaignList[campaign].ID;
campaigns.add(option);
}
}
}
else {
console.log("Int-CA-onCampaigns: No campaigns");
}
}
/*********************Call events*********************/
/**
* @description Detect if the phone number is blacklist.
* @event numberOnDoNotCallList
*/
function numberOnDoNotCallList() {
printToConsole("numberOnDoNotCallList");
console.log("Int-CA-numberOnDoNotCallList");
}
/**
* @description Catch the end of the call.
* @event onCallEnds
* @param {JSON} callData Contains the dialog time and the callkey of the finished call.
* @example {dialogTime:int, callKey:string}
* @example {dialogTime:125, callKey:"0000-1"}
* @tutorial OnCallEnd
*/
function onCallEnds(message) {
console.log("Int-CA-onCallEnds", message);
document.getElementById("endCalldialogTxt").value = message.dialogTime;
document.getElementById("endCallKeyTxt").value = message.callKey;
printToConsole("Call completed with " + message.dialogTime + " seconds of dialog time.");
}
/**
* @description Catch the call data once it has been connected.
* @param {json} callData Contains the information of the current call.
* @example
{
Agent: {ID: int, userName: string},
AllowACDCallBack : bool ,
CalKey : string ,
CallId : int ,
CallOutId : int ,
CallType : uint ,
DNIS: string ,
DataContact : Array(5) [string, string, string, string, string] ,
Description : string ,
EngineId : uint ,
Id : uint ,
IsACDTransfer : false ,
IsQueueCall : bool ,
Phone : string ,
Port : int ,
WaitingTime : int ,
WrapUpTime : int ,
holdTime : bool
}
* @example
{
Agent: {ID: 94, userName: "daniAgent"},
AllowACDCallBack : true ,
CalKey : "" ,
CallId : 1323 ,
CallOutId : 2438 ,
CallType : 2 ,
DNIS : "" ,
DataContact : ["Data1", "Data2", "Data3", "Data4", "Data5"] ,
Description : "NormalDna" ,
EngineId : 1 ,
Id : 3 ,
IsACDTransfer : false ,
IsQueueCall : false ,
Phone : "2025" ,
Port : 3 ,
WaitingTime : 0 ,
WrapUpTime : 600 ,
holdTime : true
}
*/
function onCallRecieved(callData) {
printToConsole("onCallRecieved");
console.log("Int-CA-onCallRecieved ", callData);
document.getElementById("dnisTxt").value = callData.DNIS;
document.getElementById("queuedTxt").value = callData.IsQueueCall;
document.getElementById("calKeyTxt").value = callData.CalKey;
document.getElementById("calloutTxt").value = callData.CallOutId;
document.getElementById("callIdTxt").value = callData.CallId;
document.getElementById("camIdTxt").value = callData.Id;
document.getElementById("camDescriptionTxt").value = callData.Description;
if (callData.DataContact) {
document.getElementById("data1Txt").value = callData.DataContact[0] ? callData.DataContact[0] : "";
document.getElementById("data2Txt").value = callData.DataContact[1] ? callData.DataContact[1] : "";
document.getElementById("data3Txt").value = callData.DataContact[2] ? callData.DataContact[2] : "";
document.getElementById("data4Txt").value = callData.DataContact[3] ? callData.DataContact[3] : "";
document.getElementById("data5Txt").value = callData.DataContact[4] ? callData.DataContact[4] : "";
}
document.getElementById("holdTxt").value = callData.holdTime;
document.getElementById("phoneTxt").value = callData.Phone;
document.getElementById("portTxt").value = callData.Port;
document.getElementById("callTypeTxt").value = callData.CallType;
document.getElementById("wrapupTimeTxt").value = callData.WrapUpTime;
// let server = window.location.hostname;
// let secureConnection = window.location.protocol;
// let url = `${secureConnection}//${server}/CenterScriptAgent?type=${callData.CallType}&cam_id=${callData.Id}&cal_key=${callData.CalKey ? callData.CalKey : callData.Phone}&username=${callData.Agent.userName}`;
// console.log("Int-CA-CenterScriptAgent", url);
//window.open(url);
}
/**
* @description Catch the summary of incoming calls in queue.<br/>
* @event onCallsOnQueue
* @param {Array} CallOnQueue
* @example [{acdID:int, nQueue:int, secondsOnQueue:int}]
* @example
[
{acdID:1,nQueue:1,secondsOnQueue:75},
{acdID:3,nQueue:3,secondsOnQueue:125}
]
*/
function onCallsOnQueue(CallOnQueue) {
console.log("Int-CA-onCallsOnQueue:", CallOnQueue);
document.getElementById("queue").innerHTML = "";
if (CallOnQueue && CallOnQueue.length >0) {
let queueTable = '';
let tbodyCallsQueue = document.getElementById("tbodyCallQueue");
tbodyCallsQueue.innerHTML = "";
for (const acd of CallOnQueue) {
if (acd.nQueue > 0 ) {
queueTable += '<tr><th scope="col">' +
acd.acdID + '</th><th scope="col">' +
acd.nQueue + '</th><th scope="col">' +
acd.secondsOnQueue + '</th></tr>';
}
}
if (queueTable=='') {
document.getElementById("queue").innerHTML = "Without call on queue";
}else{
tbodyCallsQueue.innerHTML = queueTable;
}
} else {
document.getElementById("queue").innerHTML = "Without call on queue";
}
}
/**
* @description Catch the new updated information from the agent in the current call.
* @param {json} callData Contains updated information of the current call (CalKey,DataContact).
* @example
{
CalKey : string ,
DataContact : Array(5) [string, string, string, string, string] ,
IsSave: bool
}
* @example
{
CalKey : "" ,
DataContact : ["Data1", "Data2", "Data3", "Data4", "Data5"],
IsSave : true
}
*
* @see UpdateDataCall
* @event onDataCallUpdated
*/
function onDataCallUpdated(newData) {
console.log("Int-CA-onDataCallUpdated",newData);
if (newData && newData.IsSave) {
document.getElementById("calKeyTxt").value = newData.CalKey;
document.getElementById("data1Txt").value = newData.DataContact[0] ? newData.DataContact[0] : "";
document.getElementById("data2Txt").value = newData.DataContact[1] ? newData.DataContact[1] : "";
document.getElementById("data3Txt").value = newData.DataContact[2] ? newData.DataContact[2] : "";
document.getElementById("data4Txt").value = newData.DataContact[3] ? newData.DataContact[3] : "";
document.getElementById("data5Txt").value = newData.DataContact[4] ? newData.DataContact[4] : "";
} else {
console.log("Could not update information");
}
}
/**
* @description Catch the manual dialing data.
* @event onDialingNumber
* @param {JSON} calloutData Contains the characteristics of the call made manually.
* @example {call_id:int, callout_id:int , camID:uint, phoneNumber:string}
* @example {call_id:1318, callout_id:2430, camID:3, phoneNumber: "2025"}
*/
function onDialingNumber(calloutData) {
console.log("Int-CA-onDialingNumber", calloutData);
document.getElementById("calloutTxt").value = calloutData.callout_id;
document.getElementById("camIdTxt").value = calloutData.camID;
document.getElementById("callIdTxt").value = calloutData.call_id;
printToConsole("Calling " + calloutData.phoneNumber + "...");
}
/**
* @description Catch the dial result if unsuccessful. <br/>
* 2: "Busy",<br/>
3: "Not Answer",<br/>
4: "Fax/Modem",<br/>
5: "NoDialTone",<br/>
8: "Other",<br/>
10: "NoService",<br/>
11: "VoiceMail/Machine",<br/>
12: "Circut Busy",<br/>
13: "Cancelled",<br/>
90: "Rejected by provider"
* @event onDialResult
* @param {int} callResult Contains the id of the dial result.
* @example {dialResult:int}
* @example {dialResult:1}
*/
function onDialResult(callResult) {
console.log("Int-CA-onDialResult", callResult);
let descripResult;
if (callResult.dialResult in DialResult) {
descripResult = DialResult[callResult.dialResult];
} else {
descripResult = "Not Exists Result";
}
printToConsole(descripResult);
}
/**
* @description Catch the error on manual calls.
* @event onErrorManualCall
* @param {int} code Contains the code of error.
* @param {String} message Contains the error.
* @example{ "code": 1098, "message": "The call cannot be completed because the campaign was not assigned to a dialing port"}
*/
function onErrorManualCall(data) {
console.warn("Int-CA-onErrorManualCall", data);
printToConsole("onErrorManualCall:" + data.code);
}
/**
* @description Catch the hold status.
* @event onHold
* @param {boolean} status Indicates if the hold is active in the current call.
* @example {true}
* @example {false}
* @see HoldCall
* @tutorial CallControl
*/
function onHold(status) {
console.log('Int-CA-onHold',status);
}
/**
* @description Mute status
* @event onMute
* @param {boolean} status Indicates if the mute is active in the current call.
* @example {true}
* @example {false}
* @see setMute
* @tutorial CallControl
*/
function onMute(status) {
console.log('Int-CA-onMute', status);
}
/**
* @description Catch the number if it is out of the time zone.
* @event timeZoneNumber
* @see makeManualCall
* @param {string} phone Phone number
* @example {"558877441"}
*/
function timeZoneNumber(number) {
console.log("Int-CA-timeZoneNumber", number);
printToConsole("TimeZoneNumber " + number);
}
/**
* @description Catch the wrong number.
* @event wrongNumber
* @param {String} phone It does not meet the dialing rules.
* @example {"558877441"}
*/
function wrongNumber(phone) {
console.warn("Int-CA-wrongNumber", phone);
printToConsole("Wrong Number:" + phone);
}
/*********************IVR*********************/
/**
* @description Catch client-side IVR completion.
* @event onIdleEnd
* @param {string} IVRInput Contains the digits entered by the customer.
* @example {string}
* @example {"1122334455"}
* @tutorial IVR
*/
function onIdleEnd(IVRInput) {
console.log("Int-CA-onIdleEnd ", IVRInput);
printToConsole("onIdleEnd: " + IVRInput);
}
/**
* @description Catch the start of selected client-side IVR.
* @event onIdleStart
* @param {string} IVRId Contains the ID of the IVR used.
* @example {string}
* @example {"1"}
* @see idleStart
* @tutorial IVR
*/
function onIdleStart(IVRId) {
console.log("Int-CA-onIdleStart ", IVRId);
printToConsole("onIdleStart: " + IVRId);
}
/**
* @description Catch the list of available IVRs.
* @event onIVRList
* @param {Array} IVRList Contains the Id and name of each of the IVRs.
* @example [{ name: string, id: int }]
* @example [{ name: "Banamex", id: 3 }, { name: "Bancomer", id: 2 }]
* @see getIVRList
* @tutorial IVR
*/
function onIVRList(IVRList) {
console.log("Int-CA-onIVRList ", IVRList);
printToConsole("onIVRList");
document.getElementById("IVRList").innerHTML = "";
let tempIVRList = document.getElementById("IVRList");
for (const element of IVRList) {
let option = document.createElement("option");
option.text = element.id + "=" + element.name;
option.value = element.id;
tempIVRList.add(option);
}
}
/*********************Call transfer events*********************/
/**
* @description Capture if the conference between the main call, the second call and the agent was successful.
* @event onConference
*/
function onConference() {
console.log('Int-CA-onConference');
printToConsole("onConference");
}
/**
* @description Catch the number of the main call indicating that it is the active call.
* @event onMainCall
* @example
* {string}
* @example
* {"2029"}
*/
function onMainCall(phone) {
console.log('Int-CA-onMainCall', phone);
printToConsole("onMainCall phone:" + phone);
}
/**
* @description Catch the new phone number that was added to the conference.
* @event onNextCall
*/
function onNextCall(phone) {
console.log('onNextCall', phone);
printToConsole("onNextCall phone:" + phone);
}
/**
* @description Catch the number of the second call indicating that it is the active call.
* @event onSecondCall
* @param {string} phone Second call number
* @example
* {string}
* @example
* {"2025"}
*/
function onSecondCall(phone) {
console.log('Int-CA-onSecondCall', phone);
printToConsole("onSecondCall phone:" + phone);
}
/**
* @description Catch the successful connection of the second call made in an assisted/blind transfer.
* @event onSecondCallConected
*/
function onSecondCallConected() {
console.log('Int-CA-onSecondCallConected');
printToConsole("onSecondCallConected:");
}
/**
* @description Catch the hangup on the second call.
* @event onSecondCallHangUp
* @param {string} Error code
* @param {string} Message code
* @example
* {
Code: string,
Message: string
}
* @example
* {
Code: "1505",
Message: "Congestión"
}
*/
function onSecondCallHangUp(status) {
console.log('Int-CA-onSecondCallHangUp',status);
if (status) {
printToConsole("onSecondCallHangUp:"+status.Message);
}else{
printToConsole("onSecondCallHangUp");
}
}
/**
* @description Catch the list of transfer options (Blind and Assisted).
* @event onTransferOptions
* @see getTransfersOptions
* @param {Array} transfersOptions Contains ACD campaigns, active agents and active numbers available to make assisted or blind transfers.
* @example
* {
* 0:[{inbound_id:uint, name:string,frame:uint}],
* 1:[{id:uint, name:string, number:string}]
* 2:[{extid:int, name:string}]
* }
* @example {
* 0:[{inbound_id:1, name:"Verificacion Compra"},{inbound_id:3, name:"Cancelacion Compra", frame:1}]
* 1:[{id:1, name:"Mesa Ayuda", phone:"2005"},{id:2, name:"Cobranza", phone:"2100"}],
* 2:[{extid: -6, name : "pacoAgent pacoAgent"},{extid: -87, name : "pacoAgent alanAgent"}],
* }
*/
function onTransferOptions(transfersOptions) {
console.log("Int-CA-onTransferOptions", transfersOptions);
const acdList = transfersOptions[0];
const phoneList = transfersOptions[1];
const agentList = transfersOptions[2];
let transferCallACD = document.getElementById("transferCallACD");
let assistedTransferCallACD = document.getElementById("assistedTransferCallACD");
transferCallACD.innerHTML = "";
assistedTransferCallACD.innerHTML = "";
if (acdList.length > 0) {
for (const acd of acdList) {
let option = document.createElement("option");
let option2 = document.createElement("option");
option.text = acd.name;
option.value = acd.inbound_id;
option2.text = acd.name;
option2.value = acd.inbound_id;
transferCallACD.add(option);
assistedTransferCallACD.add(option2);
}
}
let transferCallPhone = document.getElementById("transferCallPhone");
let assistedTransferCallPhoneNumber = document.getElementById("assistedTransferCallPhoneNumber");
transferCallPhone.innerHTML = "";
assistedTransferCallPhoneNumber.innerHTML = "";
if (phoneList.length > 0) {
for (const phone of phoneList) {
let option = document.createElement("option");
let option2 = document.createElement("option");
option.text = phone.name;
option.value = phone.number;
option2.text = phone.name;
option2.value = phone.number;
transferCallPhone.add(option);
assistedTransferCallPhoneNumber.add(option2);
}
}
let transferCallAgent = document.getElementById("transferCallAgent");
let assistedTransferCallAgent = document.getElementById("assistedTransferCallAgent");
transferCallAgent.innerHTML = "";
assistedTransferCallAgent.innerHTML = "";
if (agentList.length > 0) {
for (const agent of agentList) {
let option = document.createElement("option");
option.text = agent.name;
option.value = agent.extid;
let option2 = document.createElement("option");
option2.text = agent.name;
option2.value = agent.extid;
transferCallAgent.add(option);
assistedTransferCallAgent.add(option2);
}
}
}
/**
* @description Capture if an online agent is not available to receive a call transfer.
* @event onUnavailableAgent
* @param {Json} unavalableAgent Unavailable agent ({agent:string, error:string})
* @example {agent:'pacoAgent', error:'AGENT_BUSY'}
*/
function onUnavailableAgent(unavalableAgent) {
console.log("Int-CA-onUnavailableAgent",unavalableAgent);
printToConsole("onUnavailableAgent:"+unavalableAgent.agent);
}
/*********************Call dispositions and reprogram calls*********************/
/**
* @description Catch the successful save of the disposition.
* @see disposeCampaingCall
* @see reprogramCampaignCall
* @see disposeCampaingCall
* @see disposeCampaingCall
* @event onDisposeApplied
* @tutorial OutboundDispositions
* @tutorial InboundDispositions
*/
function onDisposeApplied() {
console.log("Int-CA-onDisposeApplied");
printToConsole("Disposition Applied");
}
/**
* @description Catch the list of availables dispositions and sub-dispisitions.
* @event onDispositions
* @param {Array} callDisposition Contains the characteristics of each disposition and sub-dispisition available.
* @example
* [{
"CanReprogram": boolean,
"Description": string,
"EndConversation": boolean,
"FinishPreview": boolean,
"Id": uint,
"Orden": uint,
"Parent": uint,
"SubDisposition": object
* }]
* @example
* [
{
"CanReprogram": false,
"Description": "Subcalificaciones",
"EndConversation": false,
"FinishPreview": false,
"Id": 4,
"Orden": 1,
"Parent": 0,
"SubDisposition": {
"1": {
"Parent": 1,
"Id": 1,
"Description": "Sub1",
"Orden": 0,
"EndConversation": false,
"CanReprogram": false
},
"2": {
"Parent": 1,
"Id": 2,
"Description": "Sub2",
"Orden": 0,
"EndConversation": false,
"CanReprogram": false
}
}
},
{
"CanReprogram": false,
"Description": "Gesti�n Efectiva",
"EndConversation": false,
"FinishPreview": false,
"Id": 1,
"Orden": 7,
"Parent": 0,
"SubDisposition": {},
},
{
"CanReprogram": true,
"Description": "Se deja recado",
"EndConversation": false,
"FinishPreview": false,
"Id": 2,
"Orden": 8,
"Parent": 0,
"SubDisposition": {},
},
{
"CanReprogram": true,
"Description": "Numero Equivocado",
"EndConversation": false,
"FinishPreview": false,
"Id": 3,
"Orden": 9,
"Parent": 0,
"SubDisposition": {}
}
]
* @tutorial OutboundDispositions
*/
function onDispositions(disposition) {
console.log("Int-CA-onDispositions ", disposition);
printToConsole("onDispositions");
let dispositionList = document.getElementById("selectDisposition");
let subDispositionList = document.getElementById("selectSubDisposition");
dispositionList.innerHTML = "";
subDispositionList.innerHTML = "";
if (disposition.length > 0) {
disposition.map((disposition) => {
let option = document.createElement("option");
option.text = disposition.Description;
option.value = disposition.Id;
dispositionList.add(option);
if (dispositionList.value !== 0) {
setSubdispositions(dispositionList.value);
}
});
}
function setSubdispositions(id) {
subDispositionList.innerHTML = "";
let option = document.createElement("option");
option.text = "";
option.value = 0;
let currentDisposition = disposition.find((disposition) => disposition.Id === parseInt(id));
let subDispositions = currentDisposition.SubDisposition;
if (Object.keys(subDispositions).length > 0) {
Object.values(subDispositions).map((subdisposition) => {
option = document.createElement("option");
option.text = subdisposition.Description;
option.value = subdisposition.Id;
subDispositionList.add(option);
});
} else {
subDispositionList.add(option);
}
}
dispositionList.addEventListener('change', () => { setSubdispositions(dispositionList.value) });
}
/**
* @description Catch the list of dispositions, sub sub-dispositions and the available telephone numbers (to carry out the reprogramming) in the system.
* @event onDispositionsAndNumbers
* @see getCampaignDispositionsAndNumbers
* @param {Object} CallDisposition It contains the characteristics of the dispositions and the list of telephone numbers (last three digits) available to reprogram the current call.
* @example
* ["dispositions":
[{
"CanReprogram": boolean,
"Description": string,
"EndConversation": boolean,
"FinishPreview": boolean,
"Id": uint,
"Orden": uint,
"Parent": uint,
"SubDisposition": object
}],
"phoneNumbers": [
string,
string
]
]
* @example
{
"dispositions": [
{
"CanReprogram": false,
"Description": "Subcalificaciones",
"EndConversation": false,
"FinishPreview": false,
"Id": 4,
"Orden": 1,
"Parent": 0,
"SubDisposition": {
"1": {
"Parent": 1,
"Id": 1,
"Description": "Sub1",
"Orden": 0,
"EndConversation": false,
"CanReprogram": false
},
"2": {
"Parent": 1,
"Id": 2,
"Description": "Sub2",
"Orden": 0,
"EndConversation": false,
"CanReprogram": false
}
}
},
{
"CanReprogram": false,
"Description": "Gesti�n Efectiva",
"EndConversation": false,
"FinishPreview": false,
"Id": 1,
"Orden": 7,
"Parent": 0,
"SubDisposition": {},
},
{
"CanReprogram": true,
"Description": "Se deja recado",
"EndConversation": false,
"FinishPreview": false,
"Id": 2,
"Orden": 8,
"Parent": 0,
"SubDisposition": {},
},
{
"CanReprogram": true,
"Description": "Numero Equivocado",
"EndConversation": false,
"FinishPreview": false,
"Id": 3,
"Orden": 9,
"Parent": 0,
"SubDisposition": {}
}
],
"phoneNumbers": [
"025",
"026"
]
}
* @tutorial OutboundDispositions
* @see getCampaignDispositionsAndNumbers
*/
function onDispositionsAndNumbers(message) {
printToConsole("onDispositionsAndNumbers");
console.log("Int-CA-onDispositionsAndNumbers ", message);
onDispositions(message.dispositions);
onPhoneNumbers(message.phoneNumbers);
}
/**
* @description Catch the list of numbers registered in the system to reprogram the current call.
* @event onPhoneNumbers
* @see getPhoneNumbers
* @param {Array} phoneNumbers Contains the last 3 digits of the numbers registered and available to carry out the reprogramming of the current call.
* @example phoneNumbers:["025","026"]
* @tutorial OutboundDispositions
*/
function onPhoneNumbers(phoneNumbers) {
printToConsole("onPhoneNumbers");
console.log("Int-CA-onPhoneNumbers", phoneNumbers);
document.getElementById("selectNumbers").innerHTML = "";
let NumberList = document.getElementById("selectNumbers");
let option = document.createElement("option");
option.text = "Select Number";
if (phoneNumbers) {
for (const element of phoneNumbers) {
if (element !== undefined && element !== "") {
let option = document.createElement("option");
option.text = element;
option.value = element;
NumberList.add(option);
}
}
} else {
NumberList.add(option);
}
}
/**
* @description Catch the summary of the registered callbacks.
* @event onReprogramCall
* @param {json} DispositionResult Contains a summary (year, month, day, hour) of the callbacks registered to date.
* @example
* {
callBacks: [{a�o:int, mes:int, dia:int, hora:int, callbacks:int},{a�o:int, mes:int, dia:int, hora:int, callbacks:int}],
endDate: "yyyy-MM-dd",
hasCallbacks: bool,
startDate: "yyyy-MM-dd"
* }
* @example
{
callBacks: [
{ "a�o": 2023, "mes": 2, "dia": 20, "hora": 14, "callbacks": 1},
{ "a�o": 2023, "mes": 2, "dia": 20, "hora": 15, "callbacks": 5},
{ "a�o": 2023, "mes": 2, "dia": 20, "hora": 16, "callbacks": 1},
{ "a�o": 2023, "mes": 2, "dia": 20, "hora": 17, "callbacks": 9},
{ "a�o": 2023, "mes": 2, "dia": 20, "hora": 18, "callbacks": 3}
],
endDate: "2023/04/21",
hasCallbacks: true,
startDate: "2023/02/20"
}
* @tutorial OutboundDispositions
*/
function onReprogramCall(message) {
console.log("Int-CA-onReprogramCall ", message);
if (message.hasCallbacks) {
printToConsole("onReprogramCall: Has registered callbacks");
}
}
/**
* @description Catch confirmation of a successful reprogram.
* @event onReprogramSuccess
*/
function onReprogramSuccess() {
console.log("Int-CA-onReprogramSuccess ");
printToConsole("ReprogramSuccess");
}
/*********************Chat administrator*********************/
/**
* @description Catch the chat history of the selected administrador.
* @event onChatHistory
* @param {json} chatHistory Contains the chat history of the selected administrador.
* @example { type: number, text: string , user: string, hour:string}
* @example { "type": 2, "text": "Hola", "user": "daniAgent", "hour": "11:30:30"}
* @example { "type": 1, "text": "Hola, ¿Comó estás?", "user": "daniAdmin", "hour": "11:30:35"}
* @tutorial ChatAdminstrator
*/
function onChatHistory(chatHistory) {
console.log("Int-CA-onChatHistory ", chatHistory);
let chatTable = '';
let tbodyChatHistory = document.getElementById("tbodyChatHistory");
tbodyChatHistory.innerHTML = "";
if (chatHistory.length > 0) {
for (const element of chatHistory) {
chatTable += '<tr><th scope="col">' +
(element.type==1?"Admin":"Agent") + '</th><th scope="col">' +
element.user + '</th><th scope="col">' +
element.text + '</th><th scope="col">' +
element.hour + '</th><th scope="col">'
}
tbodyChatHistory.innerHTML = chatTable;
}
}
/**
* @description Catch the list of online administrators.
* @event onAdministrators
* @param {Array} Administrators Contains the list of online administrators (ID,username).
* @example [{ID: uint, Username: string},{ID: ID, Username : string}]
* @example [{ID: 1, Username: 'root'},{ID: 16, Username : "daniAdmin"}]
* @see getSupervisorsToChat
* @tutorial ChatAdminstrator
*/
function onAdministrators(array) {
console.log("Int-CA-onAdministrators ", array);
document.getElementById("selectAdmins").innerHTML = "";
document.getElementById("selectAdminHistory").innerHTML = "";
let adminList = document.getElementById("selectAdmins");
let adminListH = document.getElementById("selectAdminHistory");
for (const element of array) {
if (element !== undefined) {
let option = document.createElement("option");
let option2 = document.createElement("option");
option.text = element.ID + "=" + element.Username;
option.value = element.Username;
adminList.add(option);
option2.text = element.ID + "=" + element.Username;
option2.value = element.Username;
adminListH.add(option2);
}
}
}
/**
* @description Catch the message sent by an administrator.
* @event onChatMessage
* @param {json} chatMessage Contains the message sent by an administrator.
* @example {administrator: string, message: string }
* @example {administrator:"root", message:"Buenos dias" }
* @tutorial ChatAdminstrator
*/
function onChatMessage(chatMessage) {
console.log("Int-CA-onChatMessage ", chatMessage);
let messageChatAdmin = document.getElementById("messageChatAdmin");
messageChatAdmin.value = messageChatAdmin.value + "\n" + chatMessage.administrator + ": " + chatMessage.message;
printToConsole(chatMessage.administrator+": "+chatMessage.message);
}
/*********************Historic records*********************/
/**
* @description Catch call history.
* @event onCallHistory
* @param {array} HistoryDataCall Contains the details of each call made.
* @example
[
{
CallId: int,
CallKey: string,
CallType: string,
Description: string,
Disposition: string,
Duration: string,
GraphicID: uint,
HidePhone: bool,
Hour: string,
IDCampEsp: unit,
Telephone: string,
selectionActive: bool
}
]
* @example
[
{
CallId: 45,
CallKey: "",
CallType: "IN",
Description: "CommonACD",
Disposition: "Se Corto la Llamada",
Duration: "00:01:35",
GraphicID: 1,
HidePhone: true,
Hour: "11:10:59",
IDCampEsp: 1,
Telephone: "1005",
selectionActive: false
},{
CallId: 96,
CallKey: "",
CallType: "OUT",
Description: "CommonCamp",
Disposition: "Gesti�n Efectiva",
Duration: "00:02:23",
GraphicID: 1,
HidePhone: true,
Hour: "11:10:41",
IDCampEsp: 1,
Telephone: "2005",
selectionActive: false
},{
CallId: 95,
CallKey: "",
CallType: "OUT",
Description: "CommonCamp",
Disposition: "Gesti�n Efectiva",
Duration: "00:05:24",
GraphicID: 1,
HidePhone: true,
Hour: "11:05:01",
IDCampEsp: 1,
Telephone: "2005",
selectionActive: false
}
]
* @see getCallHistory
* @tutorial HistoricRecords
*/
function onCallHistory(data) {
console.log("Int-CA-onCallHistory ", data);
let callLogData = data;
let callLogTable = '';
let tbodyCallHistory = document.getElementById("tbodyCallHistory");
tbodyCallHistory.innerHTML = "";
if (callLogData.length > 0) {
for (const element of callLogData) {
callLogTable += '<tr><th scope="col">' +
element.Hour + '</th><th scope="col">' +
element.Telephone + '</th><th scope="col">' +
element.Duration + '</th><th scope="col">' +
element.CallKey + '</th><th scope="col">' +
element.Description + '</th><th scope="col">' +
element.Disposition + '</th></tr>';
}
tbodyCallHistory.innerHTML = callLogTable;
}
}
/**
* @description Capture the history of the unavailable status.
* @event onUnavailableHistory
* @param {Array} UnavailableStatusHistory Contains the details of each use of the unavailable status.
* @example
[
{ Description:string,
Count:int,
Max:string,
Time:String,
Total:String,
TypeNotReadyId:int,
Detail:[{time:string,hour:string,"TypeNotReadyId":int}]
}
]
* @example
[
{
"Count": 2,
"Description": "Tocador",
"Detail": [
{
"Hour": "13:35:51",
"Time": "00:16:44",
"TypeNotReadyId": 3
},
{
"Hour": "18:44:30",
"Time": "00:00:11",
"TypeNotReadyId": 3,
}
],
"Frame": 3,
"Max": "00:00:00",
"Time": "00:16:55",
"Total": "n",
"TypeNotReadyId": 3,
},
{
"Count": 1,
"Description": "Con Cliente",
"Detail": [
{
"Hour": "18:39:39",
"Time": "00:00:16",
"TypeNotReadyId": 4,
}
],
"Frame": 4,
"Max": "00:00:00",
"Time": "00:00:16",
"Total": "n",
"TypeNotReadyId": 4,
}
]
* @see getUnavailableHistory
* @tutorial HistoricRecords
*/
function onUnavailableHistory(data) {
console.log("Int-CA-onUnavailableHistory ", data);
let NotAvailableHistory = document.getElementById("tbodyUnavailableHistory");
if (data) {
let callLogUnAvailable = '';
let array = data;
NotAvailableHistory.innerHTML = "";
for (const element of array) {
let history = element;
callLogUnAvailable += '<tr>'
let statusName = history.Description;
let accumulatedTime = history.Time;
let count = history.Count;
let maxTime = history.Max;
let total = history.Total;
callLogUnAvailable += "<td>" + statusName + "</td>";
callLogUnAvailable += "<td>" + accumulatedTime + "</td>";
callLogUnAvailable += "<td>" + count + "</td>";
callLogUnAvailable += "<td>" + maxTime + "</td>";
callLogUnAvailable += "<td>" + total + "</td>";
callLogUnAvailable += '</tr>'
}
tbodyUnavailableHistory.innerHTML = callLogUnAvailable;
}
}
/*********************Auxiliar Events*********************/
/**
* @description Catch the list of Auxiliar Readys.
* @event onAuxiliarTypes
* @param {json} auxiliarList Contains the message sent by Agent Kolob.
* @example {auxiliarList: AdminPasswordRequired: false, AuxiliaryRestricted: false, Color: 1, Description: "Auxiliar1", TipoReadyAuxiliar_Id: 1}
*/
function onAuxiliarTypes(auxiliarList){
console.log("Int-CA-onAuxiliarTypes", auxiliarList);
let auxiliarReadyList = document.getElementById("selectAuxiliarReadys");
auxiliarReadyList.innerHTML = "";
for (const auxiliar of auxiliarList) {
if (auxiliar !== undefined) {
let option = document.createElement("option");
option.text = auxiliar.TipoReadyAuxiliar_Id + ". " + auxiliar.Description;
option.value = JSON.stringify({
AdminPasswordRequired: auxiliar.AdminPasswordRequired,
AuxiliaryRestricted: auxiliar.AuxiliaryRestricted,
Color: auxiliar.Color,
Description: auxiliar.Description,
TipoReadyAuxiliar_Id: auxiliar.TipoReadyAuxiliar_Id,
});
auxiliarReadyList.add(option);
}
}
}
/**
* @description Catch the current status of Auxiliar Ready.
* @event onAuxiliarReadyStatus
* @param {json} auxStatus Contains the message sent by Agent Kolob.
* @example {auxStatus: 1. Disponible especial - Atenci�n de WhatsApp}
* @example {auxStatus: Ready}
* @example {auxStatus: Auxiliary Restricted by Supervisor}
*/
function onAuxiliarReadyStatus(auxStatus) {
console.log("Int-CA-onAuxiliarStatus", auxStatus);
document.getElementById("auxiliarReadyStatus").value = auxStatus;
}
/*********************Errors*********************/
/**
* @description Catch error when trying to get out of an unavailable state.
* @event errorOnAvailableStatus
* @param {json} data {message: string}
*/
function errorOnAvailableStatus(data) {
console.warn("Int-CA-errorOnAvailableStatus", data);
printToConsole("errorOnAvailableStatus: " + data.Message);
}
/**
* @description Catch error when it comes to getting the call history.
* @see getCallHistory
* @event errorOnCallHistory
* @param {json} data {code:int, message:string}
*/
function errorOnCallHistory(data) {
console.warn("errorOnCallHistory", data);
printToConsole("errorOnCallHistory: " + data.code + " - " + data.message);
}
/**
* @description Catch error when trying to get list of available dial campaigns.
* @event errorOnCampaignsRelated
* @param {json} data {code: int,message: string}
*/
function errorOnCampaignsRelated(data) {
console.warn("errorOnCampaignsRelated", data);
printToConsole("errorOnCampaignsRelated: " + data.code + " - " + data.message);
}
/**
* @description Catch error when trying to get list of available admins.
* @event errorOnChatAdministratorsList
* @todo Revisar
* @param {json} data {code: int,message: string}
*/
function errorOnChatAdministratorsList(error) {
console.warn("errorOnChatAdministratorsList", error);
printToConsole("errorOnChatAdministratorsList");
printToConsole(" " + error.code + "-" + error.message);
}
/**
* @description Catch error when trying to perform manual dialing.
* @todo Revisar
* @event errorOnDialProcess
* @param {json} data {code: int, message: string}
*/
function errorOnDialProcess(data) {
console.warn("errorOnDialProcess", data);
printToConsole("errorOnDialProcess: " + data.code + " - " + data.message);
}
/**
* @description Catch error when trying to dispose a call.
* @event errorOnDispose
* @see disposeCampaingCall
* @see reprogramCampaignCall
* @see disposeACDCall
* @see reprogramAcdCall
* @param {json} data {code:int, message:string}
*/
function errorOnDispose(error) {
console.warn("errorOnDispose", error);
printToConsole("errorOnDispose ");
printToConsole(error.code + "-" + error.message);
}
/**
* @description Catch error while trying to get list of dispositions.
* @see getACDDispositions
* @see getCampaignDispositions
* @event errorOnDispositionList
* @param {json} data {code:int, message:string}
*/
function errorOnDispositionList(data) {
console.warn("errorOnDispositionList", data);
printToConsole("errorOnDispositionList: " + data.code + " - " + data.message);
}
/**
* @description Catch error when trying to select unassigned disposition.
* @event errorOnDispositionSelected
* @param {json} data {code:int, message:string}
*/
function errorOnDispositionSelected(data) {
console.warn("errorOnDispositionSelected", data);
printToConsole("errorOnDispositionSelected: " + data.code + " - " + data.message);
}
/**
* @description Catch error while trying to get list of dispositions and phone numbers.
* @event errorOnDispositionsPhonesList
* @param {json} data {code:int, message:string}
*/
function errorOnDispositionsPhonesList(data) {
console.warn("errorOnDispositionsPhonesList", data);
printToConsole("errorOnDispositionsPhonesList: " + data.code + " - " + data.message);
}
/**
* @description Catch error when trying to send DTMF tones.
* @event errorOnDTMFJS
* @see DTMFDigit
* @param {json} data {code: int, message: string}
*/
function errorOnDTMFJS(data) {
console.warn("errorOnDTMFJS", data);
}
/**
* @description Catch error while trying to get list of available IVRs.
* @todo no implementado
* @event errorOnIVRTransfer
* @param {json} data {code: int,message: string}
*/
function errorOnIVRTransfer(data) {
console.warn("errorOnIVRTransfer", data);
}
/**
* @description Catch error when trying to change agent password.
* @event onErrorPasswordUpdate
* @param {json} data {code: int, message: string}
* @example //var message=[{id: 5002, description: "Ingrese al menos 8 caracteres"},
* {id: 5006, description: "Ingrese al menos una may�scula, una min�scula y un n�mero"}]
* @see ChangePassword
* for (i = 0; i < message.length; i++) {
* if (message[i].description) {
* printToConsole(message[i].description);
* }
* }
*/
function errorOnPasswordChange(data) {
console.warn("errorOnPasswordChange", data);
if (data && data.code) {
printToConsole("onError: " + data.code + " - " + data.message);
}
}
/**
* @description Catch error while trying to get list of phone numbers.
* @event errorOnPhoneNumbersList
* @param {json} data {code:int, message:string}
*/
function errorOnPhoneNumbersList(data) {
console.warn("errorOnPhoneNumbersList", data);
printToConsole("errorOnPhoneNumbersList: " + data.code + " - " + data.message);
}
/**
* @description Catch error when trying to put agent in unavailable state.
* @event errorOnUnavailableStatus
* @param {json} data {code:int, message:string}
* @see setOnUnavailableStatus
*/
function errorOnUnavailableStatus(data) {
console.warn("errorOnUnavailableStatus ", data);
printToConsole("errorOnUnavailableStatus: " + data.code + " - " + data.message);
}
/**
* @description Catch error when trying to get unavailable history.
* @see getUnavailableHistory
* @event errorOnUnavailableStatusHistory
* @param {json} data {code:int, message:string}
*/
function errorOnUnavailableStatusHistory(data) {
console.warn("errorOnUnavailableStatusHistory", data);
printToConsole("errorOnUnavailableStatusHistory: " + data.code + " - " + data.message);
}
/**
* @description Catch error when trying to update call info.
* @todo falta implementar
* @event errorOnUpdateDataCall
* @param {json} data {code: int, message: string}
* @see UpdateDataCall
*/
function errorOnUpdateDataCall(data) {
console.warn("errorOnUpdateDataCall", data);
}
/**
* @description Catch error when attempting to perform some method in an invalid state.
* @event onError
* @param {json} data {code: int, message: string}
* @example //var data= {code:7, message:"Estado no valido"}
* console.warn("codeError:",data.code,"MessageError:",data.message);
*/
function onError(data) {
console.warn("onError ", data);
printToConsole("onError: " + data.code + " - " + data.message);
}
/**
* @description Catch error when trying to update agent password.
* @event onErrorPasswordUpdate
* @param {json} data {code: int, message: string}
* @example //var message=[{id: 5002, description: "Ingrese al menos 8 caracteres"},
* {id: 5006, description: "Ingrese al menos una may�scula, una min�scula y un n�mero"}]
* @see ChangePassword
* for (i = 0; i < message.length; i++) {
* if (message[i].description) {
* printToConsole(message[i].description);
* }
* }
*/
function onErrorPasswordUpdate(message) {
console.warn("onErrorPasswordUpdate", message);
if (message) {
for (const element of message) {
if (element.description) {
printToConsole("onErrorPasswordUpdate id:" + element.id + ", description:" + element.description);
}
}
}
}
/**
* @description Catch error when trying to login.
* @event remoteLoginError
* @param {json} data { code:int, message:string }
* @example //remoteLoginError { code: 1024, message: "Contrase�a inv�lida" }
* function remoteLoginError(data) {
* console.warn("codeError:",data.code,"MessageError:",data.message);
* }
* @see login
*/
function remoteLoginError(message) {
console.warn("remoteLoginError ", message);
printToConsole("remoteLoginError: " + message.code + " - " + message.message);
}
/**
* @description Catch error when trying to get list readys auxiliar.
* @see getReadysAuxiliar
* @event errorOnReadysAuxiliar
* @param {json} data
* @example {"Error consulting database."}
*/
function errorGetAuxiliarReadys(data) {
console.warn("errorGetAuxiliarReadys", data);
}
/**
* @description Catch error when password is incorrect in readys auxiliar.
* @see setReadysAuxiliar
* @event errorPasswordAuxiliarReady
* @param string
* @example 'Passwords do not match.'
*/
function errorPasswordAuxiliarReady(data) {
console.warn("errorPasswordAuxiliarReady", data);
}
/*********************Alerts*********************/
/**
* @description Catch the alert of a scheduled call.
* @event onAlerts
* @param {json} data {message: string}
*/
function onManualCallReprogramed(data) {
console.warn("Int-CA-onManualCallReprogramed", data);
printToConsole("onManualCallReprogramed: " + data.message);
}
/**
* @description Catch the alert of a state machine disconnection.
* @event onAlerts
* @param {json} data {message: string}
*/
function onDisconnected(data) {
console.warn("Int-CA-onDisconnected", data);
printToConsole("onDisconnected: " + data.message);
}
/*********************Helpers*********************/
function changeHistory() {
let text = document.getElementById("NotAvailablesHist");
text.value = document.getElementById("NotAvailablesHistory").value;
}
function printToConsole(message) {
document.getElementById("textDebug").value = document.getElementById("textDebug").value + "\n" + message;
}
function secondsToFormat(seconds) {
seconds = Number(seconds);
let h = Math.floor(seconds / 3600);
let m = Math.floor(seconds % 3600 / 60);
let s = Math.floor(seconds % 3600 % 60);
let hDisplay = h > 0 ? h + (h == 1 ? " hour, " : " hours, ") : "";
let mDisplay = m > 0 ? m + (m == 1 ? " minute, " : " minutes, ") : "";
let sDisplay = s > 0 ? s + (s == 1 ? " second" : " seconds") : "";
return hDisplay + mDisplay + sDisplay;
}