Event Handler

Author: TeamJodo 651 views

Event handler is important part of communication between Jodo and Business Application. Events sent by Jodo are received in this method and processed as required. It is recommended not to block this method and push events in queue for processing if it takes longer time.

				
					function callURL(a)
{
    console.log("Response from Jodo World ::" + a);
    var data = JSON.parse(a);
    var ncommand = JSON.stringify(data.command);
    var message = JSON.stringify(data.message);
    console.log("command: " + ncommand + " message: " + message);
    try
    {
        if (data.command === "astatus")
        {
            if (data.message === "Available" || data.message === "available")
            {
                callflag = 0;
                // Agent is available to receive calls
                console.log("Agent is available to receive calls");
                document.getElementById("acsstatus").innerHTML = "Available";
                // disable / hide Avaiable button and show / enable Not Available button
            }
            if (data.message === "NotAvailable" || data.message === "notavailable")
            {
                // Agent is available to receive calls
                console.log("Agent is Not available to receive calls");
                document.getElementById("acsstatus").innerHTML = "Not Available";
                // disable / hide Not Avaiable button and show / enable Available button
            }
            else if (data.message === "Dialing" || data.message === "dialing")
            {
                // Call is being dialed
                document.getElementById("acsstatus").innerHTML = "Dialing";
                // disable / hide Not Avaiable / Avaiable / Dial button
            }
            else if (data.message === "Talking" || data.message === "talking")
            {
                // Agent is talking to customer
                // Show & Enable Hold Button
                document.getElementById("acsstatus").innerHTML = "Talking";
                // disable / hide Not Avaiable / Avaiable / Dial button
                $("#callend").show();
                 $("#callhold").show();
                $("#callunhold").hide();
            }
            else if (data.message === "preview")
            {
                // Agent entered in preview mode
                document.getElementById("acsstatus").innerHTML = "Preview";
            }
            else if (data.message === "calltransfer")
            {
                // Agent entered in calltransfer mode
                document.getElementById("acsstatus").innerHTML = "calltransfer";
            }
            else if (data.message === "EndCall")
            {
                // End call successful
                // Enable MakeCall button
                $("#callend").hide();
                $("#callhold").hide();
                $("#callunhold").hide();
                $("#dispoLable").show();
                $("#masterid").show();
                $("#resonId").show();
                $("#idSavebtn").show();
            }
            else if (data.message === "EndCallFailed")
            {
                // End call failed               
            }
            else if (data.message === "WrapUp" || data.message === "wrapup")
            {
                // Agent staus changed to Wrapup / AUX
                // Show Disposition List
                document.getElementById("acsstatus").innerHTML = "Wrapup";
            }
        }
        else if (data.command === "holdsuccess")
        {
            // disable hold button & enable unhold button
        }
        else if (data.command === "holdfailed")
        {
            // disable hold button & enable unhold button
        }
        else if (data.command === "unholdsuccess")
        {
            // enble hold button & disable unhold button
        }
        else if (data.command === "unholdfailed")
        {
            // enble hold button & disable unhold button
        }
        else if (data.command === "docpush")
        {
            // received request to show document
            // To be added in future release
        }
        else if (data.command === "video")
        {
            // received request to show video
            // To be added in future release
        }
        else if (data.command === "callsavesuccess")
        {
            $("#dispoLable").hide();
            $("#masterid").hide();
            $("#resonId").hide();
            $("#idSavebtn").hide();
            alert("Data Saved Successfully");
        }
        else if (data.command === "callsavefailed")
        {
            alert("Failed to save data");
        }
        else if (data.command === "ivrinputs")
        {
            // IVR Inputs
            // Show in List
            // To be added in future release
        }
        else if (data.command === "screenpop")
        {
            a = JSON.parse(message);
            var currenttryno = a.currenttryno;
            var sessionid_calllist = a.sessionid_calllist;
            var customercode = a.customercode;
            var systemuniquecallid = a.systemuniquecallid;
            var screenpopfile = a.screenpopfile;
            var timezone = a.timezone;
            var acssessionid = a.acssessionid;
            var command = a.command;
            var languageid = a.languageid;
            var end = a.end;
            var dnis = a.dnis;
            var crmuniqueid = a.crmuniqueid;
            var hold = a.hold;
            var screenpoptype = a.screenpoptype;
            var requestdatetime = a.prrequestdatetimeocessid;
            var calluniqueid = a.calluniqueid;
            var usertransfer = a.usertransfer;
            var autoflag = a.autoflag;
            var screenconnector = a.screenconnector;
            var calltypedescription = a.calltypedescription;
            var crmsave = a.crmsave;
            var mediatype = a.mediatype;
            var processid = a.processid;
            var phone_no = a.telephoneno;
            var calltype = a.calltypeid;
            document.getElementById('phoneNo').value = phone_no;
        }
    }
    catch (e) {
    }
}
///// Set event callback handler
onJodoEventReceived (callURL);
				
			

Events

EventDescription
screenpopThis event is triggered when new call is received. Customer phone number is received in this event
ivriputsThis event is triggered when input entered by caller are sent
astatusThis event is triggered when user status is changed at server end. Different status reasons are sent in the event which needs to be processed
holdsuccessRequest to Hold Call was successful
holdfailedRequest to Hold Call was failed
unholdsuccessRequest to Unhold Call was successful
unholdfailedRequest to Unhold Call was failed
docpushReceived doccument from other end
videoReceived video call request from other end
callsavesuccessSave call request was successful