Tutorial: 12. Outbound calls disposition

12. Outbound calls disposition

Disposition the call

getCampaignDispositions

To retrieve the outbound calls dispositions and it returns the event: onDispositions

nuxibaIntegration.getCampaignDispositions(1);

Event onDispositions

Returns the dispositions and subdispositions list

LoadDisposition is a generic function to fill the 'selects' of dispositions and subdispositions

/**
 * @description dispositions and subdispositions list
 * @event onDispositions
 * @param {json} callDisposition {
 * dispositions:[{id:int,finishPreview:int,keepOnDial:int,name:string,
 *  subDispositions:[{id:int,finishPreview:int,keepOnDial:int,name:string}]
 *  }]
 * }
 * @@example 
 * {
 * dispositions:[
 *  {
 *      id:1, finishPreview:0, keepOnDial:0, name:"Gestion efectiva", subDispositions: null},
 *  {
 *      id:2, finishPreview:1, keepOnDial:0, name:"Numero Equivocado", 
 *      subDispositions: [ {id:2, finishPreview:1, keepOnDial:0, name:"Numero Equivocado"}]
 *  }
 * ]
 * }
 * @tutorial OutboundDispositions 
 */
function onDispositions(disposition) {
    console.log("onDispositions ", disposition);
    printToConsole("onDispositions");

    document.getElementById("selectDisposition").innerHTML = "";
    let dispositionList = document.getElementById("selectDisposition");


    let option = document.createElement("option");
    option.text = "Select Disposition";
    option.value = 0;
    if (disposition.dispositions.length === 0) {
        dispositionList.add(option);
    } else {

        for (i = 0; i < disposition.dispositions.length; i++) {
            if (disposition.dispositions[i]) {
                let option = document.createElement("option");
                option.text = disposition.dispositions[i].name;
                option.value = disposition.dispositions[i].id;
                dispositionList.add(option);
            }
        }

    }
    dispositionList.addEventListener('change', function (event) {
        var dispositionId = event.target.value;
        var sub;
        for (i = 0; i < disposition.dispositions.length; i++) {
            if (disposition.dispositions[i] && disposition.dispositions[i].id == dispositionId) {
                sub = disposition.dispositions[i].subDispositions;
                break;
            }
        }
        let subDispositionList = document.getElementById("selectSubDisposition");
        subDispositionList.innerHTML = "";

        let option = document.createElement("option");
        option.text = "without SubDisposition";
        option.value = 0;

        if (!sub) {
            subDispositionList.add(option);
            console.log("selectSubDisposition", sub);
        }
        else {
            for (var key in sub) {
                if (sub.hasOwnProperty(key)) {
                    let option = document.createElement("option");
                    option.text = sub[key].name;
                    option.value = sub[key].id;
                    subDispositionList.add(option);
                }
            }
        }

    });
}

getCampaignDispositionsAndNumbers

To return the dispositions and sub dispositions list as well as loaded phone numbers needed to make callbacks, you will need the callOutId and you can check it out: Call Information, wich returns the event: onDispositionsAndNumbers

nuxibaIntegration.getCampaignDispositionsAndNumbers(1,10);

onDispositionsAndNumbers

Returns the dispositions and sub dispositions list as well as loaded phone numbers.
LoadDisposition is a generic function to fill the 'selects' of dispositions and subdispositions

/**   
 * @description  To return the dispositions and sub dispositions list as well as loaded phone numbers you will have to execute the method: getCampaignDispositionsAndNumbers
 * @event onDispositionsAndNumbers 
 * @param {json} CallDisposition {
 * allowManualNumber: bool, <br/>
 * dispositions:[{id:int,finishPreview:int,keepOnDial:int,name:string, <br/>
 *      subDispositions:[{id:int,finishPreview:int,keepOnDial:int,name:string}] <br/>
 *          }] <br/>
 *      }, <br/>
 * phoneNumbers:array <br/>
 * }
 * @example 
 * {
 * allowManualNumber: true,
 * dispositions:[
 *  {
 *      id:1, finishPreview:0, keepOnDial:0, name:"Gestion efectiva", subDispositions: null},
 *  {
 *      id:2, finishPreview:1, keepOnDial:0, name:"Numero Equivocado", 
 *      subDispositions: [ {id:2, finishPreview:1, keepOnDial:0, name:"Numero Equivocado"}]
 *  }
 * ],
 * phoneNumbers:["11078510","5530085168"]
 * }
 * @see getCampaignDispositionsAndNumbers
 */
function onDispositionsAndNumbers(CallDisposition) {
    console.log("onDispositionsAndNumbers");
    var isAllowManualNumber = CallDisposition.allowManualNumber
        $("#allouwNumberOutSpan").html(isAllowManualNumber);
        onDispositions(event, CallDisposition);
        var dataPhoneNumber = { data: CallDisposition.phoneNumbers };
        if (isAllowManualNumber) {
            $('.allouwNumberOutVisisble').show();
        } else {
            $('.allouwNumberOutVisisble').hide();
        }
        onPhoneNumbers(dataPhoneNumber);
}

getPhoneNumbers

Redturns the phone numbers linked to the call which returns the event: onPhoneNumbers

getPhoneNumbers(1);

onPhoneNumbers

Returns an array with the list of saved phone numbers in the system

/**
 * @description Carga lista de Numeros del registro por el calloutId
 * @param {event} event 
 * @param {json} data 
 */
function onPhoneNumbers(phoneNumbers) {
    console.log("onPhoneNumbers", phoneNumbers);
    var array = phoneNumbers;
    if (array) {
        listPhoneNumbersDisp.html("");
        for (var i = 0; i < array.length; i++) {
            if (array[i]) {
                option = $("<option>").attr("value", array[i]).html(array[i]);
                listPhoneNumbersDisp.append(option);
            }
        }
    }
}

disposeCampaingCall

Disposition a call without callback which returns a on success event onDisposeApplied

disposeCampaingCall(1, 1, 123, 0);

Evento onDisposeApplied

On sucess calls the next event

/**
 * @description When disposition a call
 * @see disposeCampaingCall
 * @see reprogramCampaignCall
 * @see disposeCampaingCall
 * @see disposeCampaingCall
 * @event onDisposeApplied
 * @tutorial OutboundDispositions
 */
function onDisposeApplied() {
    console.log("onDisposeApplied");    
}