Auto Completing Task
    • Dark
      Light

    Auto Completing Task

    • Dark
      Light

    Article summary

    This section deals with task auto completion when the outcome is set in the Campaign Manager gadget. A method CallBackMethod is used to receive the messages from outside. When an outcome is set in the Gadget or when Workspace is configured in CRM Container, the gadget sends a post message to the Flex Plug-in to complete the Task.

    Postmessage Name for Auto Completing: AutoCompleteSID

    The following block includes the Web Socket Connection Establishment Postmessage from the Gadget:

    Post Message Name for Web Socket Establishment: RequestForAgentID

    function CallBackMethod(event) {
            console.log(event);
            if (event.hasOwnProperty("source")) {
            } else {
              if (event != undefined && event != "" && event != null) {
                if (typeof event === "string") {
                  if (event.indexOf("AutoCompleteSID") > -1) {
                    console.log(event);
                    var reservSID = "";
                    reservSID = JSON.parse(event.split("~")[1]);
                    var AgentID = "";
                    var LCMKey = "";
                    var defaultOutcome = "";
                    var LCMKeywrap = "";
                    var DisconnectMessage = "";
                    AgentID = event.split("~")[5];
                    LCMKey = event.split("~")[3];
                    defaultOutcome = event.split("~")[7];
                    LCMKeywrap =
                      LCMKey +
                      "#" +
                      defaultOutcome +
                      "#" +
                      AgentID +
                      "#" +
                      DisconnectMessage;
                    //Auto Wrapup task once outcome is set
                    flex.Actions.invokeAction("CompleteTask", {
                      sid: reservSID.ReservationSID,
                    });
                  }
                  else if (event.indexOf("RequestForAgentID") > -1) {//to establish websocket connection
                    var AgentID = manager.store.getState().flex.worker.activity._worker.sid;
                    if (AgentID != "" && AgentID != undefined && AgentID != null) {
                        var Prefix = "WK";
                        if (AgentID.indexOf(Prefix) != 1) {
                            AgentID = AgentID.replace(Prefix, "");
                            console.log("RequestForAgentID" + AgentID);
                        }
        
                    }
                    var win = document.getElementsByTagName("iframe")[0].contentWindow;
                    //win.window.postMessage("AgentIDToOpenSocket~" +AgentID, "*");
                    if (win != undefined) {
                        win.window.postMessage("AgentIDToOpenSocket~" + AgentID + "~WorkerName~" + WorkerName + "~AccountSID~" + AccountSID + "~WorkerActivity~" + ActivityName + "~ActivityAvailable~" + ActivityAvailable + "~WorkspaceSID~" + WorkspaceSID, "*");
                    }
                  }
                }
              }
              
            }
          }

    This completes deployment of functions as services.


    Was this article helpful?

    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.
    ESC

    Eddy AI, facilitating knowledge discovery through conversational intelligence