@kmhgmbh/dialer-vue-components
Version:
VueJS components for telephony and dialer functions
1,275 lines (1,106 loc) • 533 kB
JavaScript
// Need to be included :
// - SWFObject.js : Open source library to load Flash component
// - wsjavascript.js : Vocalcom WS library
var agentlink_object = null;
var agentlink_object_path = "Flash/";
var timezone_agent = "";
// var gecko is defined in an other Hermes.Net script not always included.
if (typeof (gecko) == "undefined")
gecko = !(document.all != null && document.getElementsByTagName != null);
/**
* AgentLink API entry point.
* @constructor
* @param {DOMObject} container - The dom object where the flash component will be added
* @property {string} AgentProxy - Adress for the CTIProxy NT Service
* @property {number} Port - Port to connect to the CTIProxy NT Service
* @property {string} Locale - Localisation to use by CTIProxy (<a href="http://www.csharp-examples.net/culture-names">complete list</a>)
* @property {string} CustomerId - Id of the Hermes.Net customer - Readonly.
* @property {CProxySupport} ProxySupport - Informations about options, proxy version, etc. Readonly.
* @property {boolean} Connected - True while proxy socket is alive. Readonly.
* @property {boolean} HasBeenConnected - True if the socket to the proxy has been connected during the instance lifetime. Readonly.
* @property {boolean} LoggedIn - True after a successul agent login, until logout or socket down. Readonly.
* @property {number} AgentCode - Id of the agent currently logged. Readonly.
* @property {string} AgentOid - Oid of the agent currently logged. Readonly.
* @property {string} AgentName - Lastname and firstname of the agent currently logged. Readonly.
* @property {string} AgentStation - Id of the statioh used by the agent. Readonly.
* @property {AgentGlobalStates} AgentState - Current Agent Global state. Readonly.
* @property {string} AgentStateLabel - Current Agent Global state as string. Readonly.
* @property {number} AgentStateDetail - Current Agent Global state detail code. Readonly.
* @property {boolean} AutoAnswer - True if the agent phone auto answer, false if agent has to answer manually. Readonly.
* @property {number} WebcamSuperviseState - Current webcam supervise state. (0 : Stopped, 1 : Started). Readonly.
* @property {boolean} IsListeningSpeechAnalytics - True if the agent is listening Speech analytics data. Readonly.
* @property {COMArray} CallInformation - Two items, one for each agent line containing {@link CallData}. Readonly.
* @property {COMArray} PauseCodes - Array of {@link PauseCode} available for this agent. Readonly.
* @property {COMArray} Contacts - Array of {@link Contact} available for this agent. Readonly.
* @property {COMArray} SuperviseGroups - Array of {@link SuperviseGroup} defined on the agent Hermes.Net site. Readonly.
* @property {COMArray} Campaigns - Array of {@link Campaign) containing all the campaigns on which the agent is affected (active or disabled). Readonly.
* @property {COMArray} ManualCampaigns - Array of {@link ManualCampaign) containing all the manual campaigns on which the agent is affected. Readonly.
* @property {COMArray} SentenceCategories - Array of {@link SentenceCategory) available for the agent. Readonly.
* @property {TelephonyContext} Telephony - Manage the telephony context (agent rights on context, opened session, etc.)
* @property {ChatContext} Chat - Manage the chat context (agent rights on context, opened session, etc.)
* @property {VoicemailContext} VoiceMail - Manage the voicemail context (agent rights on context, opened session, etc.)
* @property {MailContext} Mail - Manage the email context (agent rights on context, opened session, etc.)
* @property {FaxContext} Fax - Manage the fax context (agent rights on context, opened session, etc.)
* @property {SocialNetworkContext} SocialNetwork - Manage the social network context (agent rights on context, opened session, etc.)
* @property {SmsContext} SMS - Manage the SMS context (agent rights on context, opened session, etc.)
* @property {HermesPhoneFormater} PhoneFormater - Object used to format phone to E164 if required
*/
function AgentLinkClass(websock_port, websock_proto) {
agentlink_object = this;
/* On insere le composant flash dans la page - si les websocket ne sont pas gérées uniquement */
this._websocket = null;
if (WebSocket) {
this._isFlashPlayer = false;
}
if ((!this._isFlashPlayer) && (!WebSocket)) {
Log("AGTLNK_JS", "ERROR", "No flash and no WebSocket is installed on the computer");
return;
}
/* private and debug for now */
this._wsPort = websock_port;
this._wsProto = websock_proto;
/* Public properties */
this.AgentProxy = "127.0.0.1";
this.Port = 9992;
this.Locale = "en-Us";
/* this.MinimumReconnectionTime = 60000; //60sec
this.RandomReconnectionDelta = 15000; //15sec */
/**
Url for the "webProxy" page to use if needed with cross domain calls.
The webservice proxy has to send request to the distant server using the "URL" GET request and by
forwading the POST request data.
If not set, no local webproxy will be used.
@type string
*/
this.LocalWebServiceProxy = "";
/**
URL to the Hermes.Net Admin Webservice.
@type string
@example
agentlink.AdminUrl = "http://YourServerIP/hermes_net_v5/admin";
*/
this.AdminUrl = "";
/**
URL to the Hermes.Net Admin Webservice to be called on the server side by the LocalWebServiceProxy.
@type string
@example
agentlink.AdminUrl = "http://YourServerLocalIP/hermes_net_v5/admin";
*/
this.AdminServerUrl = "";
/**
URL to the Hermes.Net OnMedia Webservice followed by the MediaServer connection information.
The MediaServer connection information is relative to the OnMediaWebservice making the call.
@type string
@example
var on_media_service = "MediaServerIP:5002";
agentlink.OnMediaWebService = "http://YourServerIP/hermes_net_v5/plateformpublication/OnMedia/Web_Service/MailService.asmx?OMS=" + on_media_service;
*/
this.OnMediaWebService = "";
/**
URL to the Hermes.Net OnMedia Webservice to be called on the server side by the LocalWebServiceProxy, followed by the MediaServer connection information.
The MediaServer connection information is relative to the OnMediaWebservice making the call.
@type string
@example
var on_media_service = "MediaServerIP:5002";
agentlink.OnMediaWebServiceServerUrl = "http://YourServerLocalIP/hermes_net_v5/plateformpublication/OnMedia/Web_Service/MailService.asmx?OMS=" + on_media_service;
*/
this.OnMediaWebServiceServerUrl = "";
/**
URL to the Hermes.Net MailEditor webservice
@type string
@example
agentlink.MailEditorWebService = "http://YourServerIP/hermes_net_v5/plateformpublication/MailEditor/Web_Service/MailEditorWS.asmx";
*/
this.MailEditorWebService = "";
/**
URL to the Hermes.Net MailEditor webservice to be called on the server side by the LocalWebServiceProxy.
@type string
@example
agentlink.MailEditorWebService = "http://YourServerLocalIP/hermes_net_v5/plateformpublication/MailEditor/Web_Service/MailEditorWS.asmx";
*/
this.MailEditorWebserviceServerUrl = "";
/**
URL to the Hermes.Net CRM Webservice.
@type string
@example
agentlink.CrmUrl = "http://YourServerIP/hermes_net_v5/CRM/";
*/
this.CrmUrl = "";
/**
URL to the Hermes.Net CRM Webservice to be called on the server side by the LocalWebServiceProxy.
@type string
@example
agentlink.CrmServerUrl = "http://YourServerLocalIP/hermes_net_v5/CRM/";
*/
this.CrmServerUrl = "";
//Read only propeties
this.CustomerId = "";
this.ProxySupport = new CProxySupport();
this.Connected = false;
this.HasBeenConnected = false;
this.LoggedIn = false;
this.AgentCode = 0;
this.AgentStation = "";
this.AgentOid = "";
this.AgentName = "";
this.AgentState = AgentGlobalStates.Off;
this.AgentStateLabel = "";
this.AgentStateDetail = 0;
this.AutoAnswer = false;
this.WebcamSuperviseState = 0;
this.IsListeningSpeechAnalytics = false;
/**
Array of possible global actions for agent. Before making a global action, you have to check if the action is in this list. Contains a list of {@link AgentActionAllowed}.
To Test if an action is allowed you can use the method {@link AgentLinkClass.ActionIsReady}
@type COMArray
*/
this.ActionsAllowed = new COMArray();
// Two empty lines.
this.CallInformation = new COMArray(); // CallData, get only
this.CallInformation._add(new CallData());
this.CallInformation._add(new CallData());
this.PauseCodes = new COMArray(); // LPauseCode, get only
this.Contacts = new COMArray(); // LContact, get only
this.Campaigns = new COMArray(); // LCampaign, get only
this.ManualCampaigns = new COMArray(); // get only
this.SuperviseGroups = new COMArray(); // LSuperviseGroup, get only
this.SentenceCategories = new COMArray(); // get only
this.PhoneFormater = new HermesPhoneFormater(); //get only
this.Telephony = new TelephonyContext(this); // TelephonyContext, get only
this.Chat = new ChatContext(this); // ChatContext, get only
this.VoiceMail = new VoicemailContext(this); // VoicemailContext, get only
this.Mail = new MailContext(this); // MailContext, get only
this.Fax = new FaxContext(this); // FaxContext, get only
this.SocialNetwork = new SocialNetworkContext(this); // SocialNetwork, get only
this.SMS = new SmsContext(this); // SmsContext, get only
/* Unused properties */
this.SupportChatDesktopShare = false;
this.MessageFilter = MessageFilterType.Keepalive;
this.ContextFilter = ContextFilters.NoFilter;
this.TraceActive = false;
/* Internals properties */
this.RunMode = ProxyRunMode.Agent;
this._version = "5.0.0";
this._fl = null;
this._qualificationCodes = new Array();
this._holidays = new Object();
this._openingHours = new Object();
this._clientHours = new Object();
this._connecting = false;
this._handshakingProgress = 0;
this._connectAttempt = 0;
this._isLogoutRequested = false; //When a logout is in progress : refuse new open_session.
this._notifySupListening = false;
this._ofcom = -1;
this._lastofcomrequest = "";
this._events = new Object(); // Conteneur de tous les events Handler
this._mediaService = null; // Web Service to connect MediaServer
this._mailEditor = null; //Web Service to connect MailEditor.
this._cbkReaderWs = null; //Web service to read callbacks
this._readToolsWs = null; //Web service infoadmin
this._crmWs = null; //Web service for acceding address book
this._historyWs = null; //Web service for acceding history
this._disconnecting = false; //is a disconnection request in progress
this._networkRecovering = false; //is a connection/loggin for networkRecovering mode
//Internal members to listen for callbacks update
this._threadcbkrunning = false;
this._threadcbktimeout = null;
this._threadcbkmediatype = ContextTypes.Global;
this._threadcbkdate = "";
this._threadcbktz = "UTC";
this._timeoutConnect = null;
//Timer to wait before sending context displayed
this._tkContextDisplayed = null;
//Timer before detecting proxy connexion lost
this._tkTTL = null;
this._dtLastMessage = new Date().getTime();
this._sp_sup_alert = false; //an alert has been sent to sup on softphone
/**
* Fired when the connection process is starting
* @event
* @example
* var fctHandler = function() {
* Log("MyLogger", "DEBUG", "agentlink is starting to connect to the CT-Proxy");
* }
* agentlink.attachEvent("OnConnectionStart", fctHandler);
*/
this.OnConnectionStart = "";
/**
* Fired on connection completion. True if connection is sucessfull. Login can be called after this event
* @event
* @param {boolean} success
* @example
* var fctHandler = function(connected) {
* Log("MyLogger", "DEBUG", "connected");
* }
* agentlink.attachEvent("OnConnect", fctHandler);
*/
this.OnConnect = "";
/**
* Fired on disconnect request completion, or when link failed after a successful connection
* @event
* @param {boolean} true if the disconnection is the result of the user choice.
* @example
* var fctHandler = function(isUserChoice) {
Log("MyLogger", "DEBUG", "disconnected. normal:" + isUserChoice);
* }
* agentlink.attachEvent("OnDisconnect", fctHandler);
*/
this.OnDisconnect = "";
/**
* Fired when the connection timeout is reached. AgentLink will try to reconnect automaticaly
* @event
* @example
* var fctHandler = function() {
Log("MyLogger", "DEBUG", "Connection timeout. Trying to reconnect in 2sec");
* }
* agentlink.attachEvent("OnConnectionTimeout", fctHandler);
*/
this.OnConnectionTimeout = "";
/**
* Fired on proxy reconnexion when recovering contexts failed.
* Interface has to be reinit
* @event
* @example
* var fctHandler = function() {
Log("MyLogger", "DEBUG", "Recover state failed on proxy reconnection");
* }
* agentlink.attachEvent("OnRecoverFailed", fctHandler);
*/
this.OnRecoverFailed = "";
/**
* User login information. Called on successfull login
* @event
* @param {int} userID - agent id
* @param {string} userName - agent name and first name
* @param {string} extension - telephony extension
* @param {ContextTypes} defaultContext - default context to display on login
* @param {boolean} isNetworkRecovering - indicate if the event is fired after an automatic reconnection on network lost
* @example
var fctHandler = function(userId, userName, station, defaultContext, isNetworkRecovering) {
if (agentlink.LoggedIn) {
Log("MyLogger", "DEBUG", "Agent is logged in");
} else {
Log("MyLogger", "DEBUG", "Agent is logged out");
}
}
}
agentlink.attachEvent("OnUserIdentification", fctHandler);
*/
this.OnUserIdentification = "";
/**
* When user change identification : notify that the Extension informations has been received
* @event
@param {int} userId - new agent id
@param {string} userPassword - new agent password
@param {Extension} extension - new extension informations
@example
var fctHandler = function(userId, userPassword, extension) {
agentlink.Login(userId, userPassword, extension.ExtensionId);
}
agentlink.attachEvent("OnUserIdentification", fctHandler);
*/
this.OnNewIdentificationReady = "";
/**
Agent state was changed. Global state, or state for a specified context
@event
@param {ContextTypes} media - context for whitch the text change
@param {AgentGlobalStates} stateCode - new agent state
@param {string} stateLabel - textual representation of the state
@example
var fctHandler = function(contextType, state, stateString) {
if (contextType == ContextTypes.Global) {
if (state == AgentGlobalStates.Off) {
Log("MyLogger", "DEBUG", "Agent is disconnected");
} else if (state == AgentGlobalStates.Pause) {
Log("MyLogger", "DEBUG", "Agent is in pause");
} else {
Log("MyLogger", "DEBUG", "Agent state : " + stateString);
}
}
}
agentlink.attachEvent("OnAgentStateChange", fctHandler);
*/
this.OnAgentStateChange = "";
/**
New session opened on one context
@event
@param {ContextTypes} context - The context where the session is opening
@param {string} sessionId - The Id of session opened
@example
var fctHandler = function(contextType, sessionId) {
switch (contextType) {
case ContextTypes.Telephony:
var sessionObj = agentlink.Telephony.GetSession();
break;
case ContextTypes.Mail:
//Get the session object that just open
var sessionObj = agentlink.Mail.GetSession(sessionId);
break;
default :
//you can do similar traitment for each other contexts
break;
}
if (sessionObj != null) {
Log("MyLogger", "DEBUG", "Session script indice : " + sessionObj.Indice);
}
}
agentlink.attachEvent("OnSessionOpen", fctHandler);
*/
this.OnSessionOpen = "";
/**
New session anonymous session opened (session with campaign not determined)
@event
@param {ContextTypes} context - The context where the session is opening
@param {string} sessionId - The Id of session opened
@example
var fctHandler = function(contextType, sessionId) {
var sessionObj = agentlink.Telephony.GetSession();
if (sessionObj != null) {
Log("MyLogger", "DEBUG", "Anonymous Session on DID : " + sessionObj.DID);
}
}
agentlink.attachEvent("OnAnonymousSessionOpen", fctHandler);
*/
this.OnAnonymousSessionOpen = "";
/**
One session anonymous session has been updated (campaigns informations have been loaded)
@event
@param {ContextTypes} context - The context where the session is updated
@param {string} sessionId - The Id of session updated
@example
var fctHandler = function(contextType, sessionId) {
var sessionObj = agentlink.Telephony.GetSession();
if (sessionObj != null) {
Log("MyLogger", "DEBUG", "The anonymous Session on DID : " + sessionObj.DID + " has been updated");
}
}
agentlink.attachEvent("OnAnonymousSessionUpdated", fctHandler);
*/
this.OnAnonymousSessionUpdated = "";
/**
Event on a previously opened sesssion
@event
@param {ContextTypes} context - The context where one session state is changing
@param {string} sessionId - The Id of session with changed state
@example
var fctHandler = function(contextType, sessionId) {
switch (contextType) {
case ContextTypes.Telephony:
var sessionObj = agentlink.Telephony.GetSession();
break;
case ContextTypes.Mail:
//Get the session object that just open
var sessionObj = agentlink.Mail.GetSession(sessionId);
break;
default :
//you can do similar traitment for each other contexts
break;
}
if (sessionObj != null) {
Log("MyLogger", "DEBUG", "New Session state : " + sessionObj.SessionStateLabel);
}
}
agentlink.attachEvent("OnSessionStateChange", fctHandler);
*/
this.OnSessionStateChange = "";
/**
One session is closed
@event
@param {ContextTypes} context - The context where one session is closing
@param {string} sessionId - The Id of session that is closing
@example
var fctHandler = function(contextType, sessionId) {
Log("MyLogger", "DEBUG", "Session " + sessionId + " has been closed");
}
agentlink.attachEvent("OnSessionClose", fctHandler);
*/
this.OnSessionClose = "";
/**
Update on session (session is passing from SearchMode to traiting. Script must me reload)
@event
@param {ContextTypes} context - The context where one session is closing
@param {string} sessionId - The Id of session that is closing
@example
var fctHandler = function(contextType, sessionId) {
Log("MyLogger", "DEBUG", "Search mode session " + sessionId + " change to online session");
}
agentlink.attachEvent("OnSessionUpdate", fctHandler);
*/
this.OnSessionUpdate = "";
/**
The transfer request is done - will be followed by the OnSessionClose event
@event
@param {ContextTypes} context - The context where one session has been transfered
@param {string} sessionId - The Id of session that is transfered
@example
var fctHandler = function(contextType, sessionId) {
Log("MyLogger", "DEBUG", "Session " + sessionId + " is transfered to another party");
}
agentlink.attachEvent("OnTransferComplete", fctHandler);
*/
this.OnTransferComplete = "";
/**
A message was received
@event
@param {ContextTypes} context - The context destinatory of the message
@param {MessageLevels} level - Type of information contains in the message
@param {string} message - The message content
@param {string} code - The message type code
@example
var fctHandler = function(mediaType, level, message, code) {
Log("MyLogger", "DEBUG", "Message CTI - Level:" + level + " - Message:" + message);
}
agentlink.attachEvent("OnInfo", fctHandler);
*/
this.OnInfo = "";
/**
An object was created/updated/deleted in admin. Show ConfigObjects enum to see the list of supported objects.
@event
@param {ConfigOperations} action - Type of action fireing the event
@param {ConfigObjects} objectType - Type of object fireing the event
@param {object} theObject - Object of wich the change occur
@example
var fctHandler = function(operation, objType, obj) {
Log("MyLogger", "DEBUG", "A change operation occure on the object type:" + objType);
}
agentlink.attachEvent("OnConfigChange", fctHandler);
*/
this.OnConfigChange = "";
/**
A queue has changed for this agent (or state of one of the queues affected). A queue is removed, started, stopped, etc.
@event
@param {ContextTypes} context - The context destinatory of the message
@param {ConfigOperations} action - Type of action fireing the event
@param {object} theObject - Object of wich the change occur
@example
var fctHandler = function(contextType, configOperation, obj) {
var context = "";
if (contextType == ContextTypes.Telephony) {
context = (obj.IsTelephonyOutbound) ? "OUTBOUND" : "INBOUND";
} else {
context = ContextNameFromEnum(contextType);
}
var operationNamed = "";
switch (configOperation) {
case ConfigOperations.Update:
operationNamed = "UPDATED";
break;
case ConfigOperations.Delete:
operationNamed = "DELETED";
break;
case ConfigOperations.Create:
operationNamed = "CREATED";
break;
}
Log("MyLogger", "DEBUG", "A queue configuration change on the context named :" + context + ". Operation:" + operationNamed);
}
agentlink.attachEvent("OnAffectationChange", fctHandler);
*/
this.OnAffectationChange = "";
/**
Fired when the list of sections allowed on one context change
@event
@param {ContextTypes} context - the context on wich the list of allowed session has changed
@param {COMArray} allowedSections - array of {@link ContextSectionsAllowed} containing the list of section allowed for the agent
@example
var fctHandler = function(contextType, allowedSections) {
var sectionsAllowedStr = "";
for (var i = 0; i < allowedSections.Count; i++) {
var sectionItem = allowedSections.Item(i);
sectionAllowedStr += sectionItem + " ";
}
Log("MyLogger", "DEBUG", "Agent can display sections :" + sectionsAllowedStr + " - on context :" + contextType);
}
agentlink.attachEvent("OnSectionsStateChange", fctHandler);
*/
this.OnSectionsStateChange = "";
/**
The number of media waiting change for this agent (on his primary, secondary and personal queue).
@event
@param {ContextTypes} context - The context where queue state change
@param {number} nbPrimary - Number of media on the agent's primary queue
@param {number} nbSecondary - Number of media on the agent's secondary queue
@param {number} nbPersonal - Number of media on the agent's personal queue
@example
var fctHandler = function(contextType, primary, secondary, personal) {
Log("MyLogger", "DEBUG", "Queue state on context " + contextType + ":" + primary + "-" + secondary + "-" + personal);
}
agentlink.attachEvent("OnQueueStateChange", fctHandler);
*/
this.OnQueueStateChange = "";
/**
A regular chat Message received
@event
@param {string} sessionId - The chat session where the message is received
@param {ChatMessageTypes} msgType - The type of message received
@param {string} message - The message received
@param {ChatterTypes} senderType - The type of message sender
@param {string} sender - Name of the message sender
@param {boolean} whisper - Indicate that the message is private for this agent or not (on chat consulation or supervisor whisper message)
@example
var fctHandler = function(sessionId, msgType, message, senderType, sender, senderName, whisper) {
Log("MyLogger", "DEBUG", "Chat message received : " + message);
}
agentlink.attachEvent("OnChatSessionMsgReceived", fctHandler);
*/
this.OnChatSessionMsgReceived = "";
/**
A chat Message received from supervisor, and if ChatMessageTypes is ChatClosed : it's the end of conversation
@event
@param {ChatMessageTypes} messageType - The type of message received. if type is ChatClosed, it's the end of the conversation
@param {string} message - The message sended by the supervisor
@param {string} chatRoomOid - The oid of the chat room where the message has been received
@param {string} supervisorName - The name of the supervisor who sends the message
@example
var fctHandler = function(messageType, message, roomOid, senderName) {
if (messageType == ChatMessageTypes.TextMessage) {
Log("MyLogger", "DEBUG", "Supervisor message received : " + message);
} else if (messageType == ChatMessageTypes.ChatClose) {
Log("MyLogger", "DEBUG", "Supervisor close the internal chatRoom with oid : " + roomOid);
}
}
agentlink.attachEvent("OnSupervisorChatMsgReceived", fctHandler);
*/
this.OnSupervisorChatMsgReceived = "";
/**
A Facebook direct message is received on the feed currently managed by the agent
@event
@param {string} sessionId - The Facebook session where the message is received
@param {string} message - Json string representing the message received
*/
this.OnFacebookDirectMsgReceived = "";
/**
Event receive a array which contain id of the fb direct message and new status need to be updated for each message
@event
@param {string} sessionId - The Facebook session where the message is received
@param {string} messagesJsonStr - Json string representing the array of message containing new status to update
*/
this.OnFacebookDirectMsgStatus = "";
/**
When the predefined phrases are loaded. This event is fired only after a call to the function {@link GetSentencesByCategory}
If sentences are already loaded, the events will be fired directly. Else, the sentences will be loaded on a webservice
@event
@param {string} groupOid - The oid of sentences group loaded
@param {COMArray} phrases - Array of sentences loaded
@example
var fctHandler = function(groupOid, phrases) {
Log("MyLogger", "DEBUG", phrases.Count + " phrases are available on group " + groupOid);
}
//attach the event one time only
agentlink.attachEvent("OnGetPhrases", fctHandler);
//Request sentences when needed.
var groupOidToLoad = "GroupOidTest";
var categoryOidToLoad = "CategoryOidTest";
agentlink.GetSentencesByCategory(groupOidToLoad, categoryOidToLoad);
*/
this.OnGetPhrases = "";
/**
When there is a change on the agent telephony line's state
@event
@param {number} lineID - The index of the telephony line where ths state change (0/1)
@param {LineStates} lineState - The new telephony line's state
@example
var fctHandler = function(lineID, lineState) {
switch (lineState) {
case LineStates.Cleared:
Log("MyLogger", "DEBUG", "Call on line " + lineID + " is terminated");
break;
case LineStates.Alerting:
Log("MyLogger", "DEBUG", "Line " + lineID + " is alerting - agent should take the call");
break;
case LineStates.Online:
Log("MyLogger", "DEBUG", "Call on " + lineID + " is established");
break;
case LineStates.Hold:
Log("MyLogger", "DEBUG", "Call on " + lineID + " is on hold");
break;
case LineStates.Dialing:
Log("MyLogger", "DEBUG", "Call on " + lineID + " is dialing");
break;
}
}
agentlink.attachEvent("OnLineStateChange", fctHandler);
*/
this.OnLineStateChange = "";
/**
When there is a change of supervisor state (Listening/Recording)
@event
@param {boolean} recording - a supervisor is listening or recording the agent active call
@param {number} nbListening - when recording is true, indicate the number of supervisor listening the agent active call
@example
var fctHandler = function(recording, nbListening) {
if ((nbListening > 0) || (recording == true)) {
Log("MyLogger", "DEBUG", "Your current call is listening by at least one supervisor");
}
}
agentlink.attachEvent("OnSupStateChange", fctHandler);
*/
this.OnSupStateChange = "";
/**
When a telephony recording is starting.
Fired for all cases of record (automatic, supervisor, agent)
@event
@param {string} filePath - the windows path of the recorded file
@param {string} sessionId - the ID of the recorded session
@example
var fctHandler = function(filePath, sessionId) {
Log("MyLogger", "DEBUG", "Your current call is being recorded");
}
agentlink.attachEvent("OnTelephonyRecordStart", fctHandler);
*/
this.OnTelephonyRecordStart = "";
/**
When a telephony recording is stopping
@event
@param {string} filePath - the windows path of the recorded file
@example
var fctHandler = function(filePath) {
Log("MyLogger", "DEBUG", "End of call recording");
}
agentlink.attachEvent("OnTelephonyRecordStop", fctHandler);
*/
this.OnTelephonyRecordStop = "";
/**
Fired when the last recording made must be deleted (for automatic record case only).
@event
@param {string} filePath - the windows path of the recorded file to delete
@example
var fctHandler = function(filePath) {
Log("MyLogger", "DEBUG", "Last recorded file will be deleted");
}
agentlink.attachEvent("OnTelephonyRecordDelete", fctHandler);
*/
this.OnTelephonyRecordDelete = "";
/**
Fired when the last recording file should be renamed, according the name strategy defined on the Hermes.Net Admin
@event
@param {string} oldPath - the windows path of the recorded file to rename
@param {string} newPath - the new file name for the recorded file
@example
var fctHandler = function(oldPath, newPath) {
Log("MyLogger", "DEBUG", "Recorded file " + oldPath + " will be renamed as :" + newPath);
}
agentlink.attachEvent("OnTelephonyRecordChangeName", fctHandler);
*/
this.OnTelephonyRecordChangeName = "";
/**
When the name of the last chat recording made must renamed, according the name strategy defined on the Hermes.Net Admin
Instead of telephony records, the renaming is at the charge of integrator (as starting the videochat record)
@event
@param {ChatSession} session - the chatsession with the record to rename
@example
var fctHandler = function(chatSession) {
Log("MyLogger", "DEBUG", "Videochat recorded file has to be renamed for session " + chatSession.SessionId);
}
agentlink.attachEvent("OnChatRecordChangeName", fctHandler);
*/
this.OnChatRecordChangeName = "";
/**
When the last chat recording must be deleted
Instead of telephony records, the renaming is at the charge of integrator (as starting the videochat record)
@event
@param {ChatSession} session - the chatsession with the record to delete
@example
var fctHandler = function(chatSession) {
Log("MyLogger", "DEBUG", "Videochat recorded file has to be deleted for session " + chatSession.SessionId);
}
agentlink.attachEvent("OnChatRecordDeleted", fctHandler);
*/
this.OnChatRecordDeleted = "";
/**
When the supervisor is showing/unshowing the agent webcam (state change)
The management of webcam video
@event
@param {string} supervisorKey - Unique key to identify the supervisor
@param {number} state - state of webcam supervising for this supervisor (0 : unwatch, 1 : watch)
@example
var fctHandler = function(supervisorKey, state) {
if (state == 1) {
Log("MyLogger", "DEBUG", "Supervisor " + supervisorKey + " is asking to watch the agent webcam");
}
}
agentlink.attachEvent("OnWebcamSuperviseStateChange", fctHandler);
*/
this.OnWebcamSuperviseStateChange = "";
/**
When production statics listened have change.
This event is fired only on contexts where the function {@link StartListeningQueueForProductionStatistics} has been called.
This statistics are sended by the Supervision Service.
@event
@param {ContextTypes} context - the context for the production statistics received
@param {ContextTypes} subContext - for Telephony only : Inbound or Outbound
@param {AgentProdStat} agentProdStats - production statistics received
@example
var fctHandler = function(context, subContext, agentProdStats) {
Log("MyLogger", "DEBUG", "Agent argued " + agentProdStats.AgentDayProd.CA + " contacts today on the context " + context);
}
//Attach the event one time only
agentlink.attachEvent("OnSupervisionDatasReceived", fctHandler);
//Will start the receiving of the event for the email context for all queues and all supervising group
agentlink.Mail.StartListeningQueueForProductionStatistics(-1, "", false);
*/
this.OnSupervisionDatasReceived = "";
/**
When the state of supervision service state change
The Supervision service is used to get the production statistics and listing agents/supervisor for transfer, consultation, manual call, etc.
@event
@param {boolean} isStarted - true when the supervision service is started, false when it is stopped
@example
var fctHandler = function(isStarted) {
if (!isStarted) {
Log("MyLogger", "DEBUG", "Supervision service has stopped - interface will works in degrated mode");
}
}
agentlink.attachEvent("OnSupervisionServiceStateChange", fctHandler);
*/
this.OnSupervisionServiceStateChange = "";
/**
Fired when personal callbacks for the current hour are received
Personnal callbacks start to be loaded periodicaly by calling the method {@link AgentLinkClass#GetContextPersonalCallbacksStart()} and stop by the method {@link AgentLinkClass#GetContextPersonalCallbackStop()}
Loading personnal callbacks for FAX / VOICEMAIL / EMAIL / SOCIAL NETWORK needs that MediaServer service is started
@event
@param {CallbackForDayPerMinute} callbacks - struct with all personal callbacks for one context / day
@example
function LZ(x) { return (x < 0 || x > 9 ? "" : "0") + x }
var fctHandler = function(callbacks) {
var count = 0;
for (var i = 0; i < callbacks.PersonalCallbacks.length; i++) {
for (var j = 0; j < callbacks.PersonalCallbacks[i].Callbacks.length; j++) {
count += callbacks.PersonalCallbacks[i].Callbacks[j].CallbacksNumber;
}
}
Log("MyLogger", "DEBUG", "Number of email personal callbacks today : " + count);
}
//Attach the event one time only
agentlink.attachEvent("OnGetContextPersonalCallbacks", fctHandler);
//Start to listen the number of personal callbacks
var dte = new Date();
var dateString = dte.getYear() + LZ(dte.getMonth() + 1) + LZ(dte.getDate());
agentlink.GetContextPersonalCallbacksStart(ContextTypes.Mail, dateString, "UTC");
*/
this.OnGetContextPersonalCallbacks = "";
/**
Fired when callbacks for the current hour are received
Next callbacks are loaded by calling the function CountNextCallbacks an a context manager
@event
@param {ContextTypes} contextType - contextType on which next callbacks are just loaded
@param {CallbackStruct[]} callbacks - list of callbacks for the next hour
@example
var fctHandler = function(contextType, callbacks) {
var count = 0;
for (var i = 0; i < callbacks.length; i++) {
count += callbacks[i].CallbacksNumber;
}
Log("MyLogger", "DEBUG", "Number of callbacks in the next hour : " + count);
}
//Attach the event one time only
agentlink.attachEvent("OnCountCallbacksComplete", fctHandler);
*/
this.OnCountCallbacksComplete = "";
/**
When the VoiceMail asked by agent start to play
@event
@param {string} voicemailSessionId - the id of voicemail playing
@example
var fctHandler = function(voiceMailId) {
Log("MyLogger", "DEBUG", "Voicemail : " + voiceMailId + " is playing");
}
//Attach the event one time only
agentlink.attachEvent("OnPlayingVoiceMail", fctHandler);
*/
this.OnPlayingVoiceMail = "";
/**
One Wav File start to play
@event
@param {string} filename - the windows path of wav file currently playing on the agent line
@example
var fctHandler = function(filename) {
Log("MyLogger", "DEBUG", "Agent is listening file : " + filename);
}
//Attach the event one time only
agentlink.attachEvent("OnPlayWavStart", fctHandler);
*/
this.OnPlayWavStart = "";
/**
One Wav File stop to play
@event
@param {string} filename - the windows path of wav file that ends to play
@example
var fctHandler = function(filename) {
Log("MyLogger", "DEBUG", "Agent ends to listen file : " + filename);
}
//Attach the event one time only
agentlink.attachEvent("OnPlayWavStop", fctHandler);
*/
this.OnPlayWavStop = "";
/**
When the client has been identified in adress book (on {@link AgentLinkClass#CrmGetClientInfos} function)
mediaNumber : phone number (or email) that permit to identify the client
The result array contains one or more clients of type Consumers
@event
@param {string} mediaKey - type of media on adress book. Valid values are "cti", "mail", "fax", "social_network", "cookie"
@param {string} mediaNumber - media value (phone number for cti, email adress for adress, etc)
@param {Array} results - Array of {@link Consumers} matching the CrmGetClientInfos requested
@example
var fctHandler = function(mediaKey, mediaNumber, results) {
Log("MyLogger", "DEBUG", results.length + " contacts with email adress " + mediaNumber + " are founds in the adress book");
}
//Attach the event one time only
agentlink.attachEvent("OnCrmReceiveClientInfo", fctHandler);
//Get a client on the adress book, identified by email
var oid_company = "YourCompanyOid"; //needed
var session = agentlink.Mail.GetSession();
agentlink.CrmGetClientInfos(oid_company, session.ContactNumber, session.SessionId, session.CrmOid, "mail", 0);
*/
this.OnCrmReceiveClientInfo = "";
/**
When the CRM save operation requested by function {@link AgentLinkClass#CrmSaveClient} is done
result value : 1 : OK, -1 : invalid phone number, -2 : save error
@event
@param {number} result - result value : 1 : OK, -1 : invalid phone number, -2 : save error
@param {Consumers} clientSaved - the client saved on this event
@param {string} mediaKey - type of media on adress book. Valid values are "cti", "mail", "fax", "social_network", "cookie"
@param {boolean} was_forced_saved - saved by agent, can set IsIdentified to 1 and IsAutoCreated to false (Integrator responsability)
@example
var fctHandler = function(result, client, mediaKey, was_forced_saved) {
if (isSaveForced) {
client.IsAutoCreated = false;
client.IsIdentified = 1;
}
if (parseInt(results, 10) == 0) {
Log("MyLogger", "DEBUG", "Contact " + client.Name + " is saved");
} else {
Log("MyLogger", "DEBUG", "Error while saving contact " + client.Name);
}
}
agentlink.attachEvent("OnSaveClientDone", fctHandler);
*/
this.OnSaveClientDone = "";
/**
When the CRM Add operation requested by function {@link AgentLinkClass#CrmAddClient} is done
@event
@param {string} guid - new guid for the added client. If null or empty : error on add
@param {Consumers} clientAdded - the client added on this event
@param {string} mediaKey - type of media on adress book. Valid values are "cti", "mail", "fax", "social_network", "cookie"
@example
var fctHandler = function(guid, client, mediaKey) {
if (guid != "") {
Log("MyLogger", "DEBUG", "Contact " + client.Name + " has been added to the adress book");
} else {
Log("MyLogger", "DEBUG", "Error while adding contact " + client.Name);
}
}
agentlink.attachEvent("OnAddClientDone", fctHandler);
*/
this.OnAddClientDone = "";
/**
When the CRM Search operation requested by function {@link AgentLinkClass#CrmSearchClient} is done
@event
@param {Array} result - Array of {@link Consumers} matching the search
@param {Consumers} client - Client struct used to perform the search
@param {string} mediaKey - type of media on adress book. Valid values are "cti", "mail", "fax", "social_network", "cookie"
@param {string} adressBookOid - oid of the adress book where the search has been done
@example
var fctHandler = function(result, client, mediaKey, adressBookOid) {
Log("MyLogger", "DEBUG", result.length " contacts matching the reference client");
}
agentlink.attachEvent("OnSearchClientDone", fctHandler);
*/
this.OnSearchClientDone = "";
/**
Fired when the requested history data is loaded, requested by function {@link AgentLinkClass#HistoryLoadClientHistory}
@event
@param {Array} results - Array of {@link CallInformation}
@param {string} askKey - Webservice call identifier (for managing more than one request at a time)
@example
var fctHandler = function(results, askKey) {
Log("MyLogger", "DEBUG", results.length " history entries are found");
}
agentlink.attachEvent("OnLoadClientHistoryDone", fctHandler);
*/
this.OnLoadClientHistoryDone = "";
/**
Fired when the chat feed requested by the function {@link HistoryLoadOfflineChatHistory} has been loaded
@event
@param {Array} results - Array of messages (type: {@link ChatElement}) for the chat entire conversation
@param {string} askKey - Webservice call identifier (for managing more than one request at a time)
@example
var fctHandler = function(results, askKey) {
Log("MyLogger", "DEBUG", results.length " messages on the history chat conversation");
}
agentlink.attachEvent("OnLoadOfflineChatHistoryDone", fctHandler);
*/
this.OnLoadOfflineChatHistoryDone = "";
/**
Fired when the voicemail information requested by function {@link AgentLinkClass#HistoryLoadOfflineVoiceMailHistory} has been loaded
@event
@param {WavInformation} wInfo - The historized wav file informations
@param {string} askKey - Webservice call identifier (for managing more than one request at a time)
@example
var fctHandler = function(wInfo, askKey) {
Log("MyLogger", "DEBUG", "Wav file for the voicemail has a duration of " + wInfo.Fileduration + " seconds");
}
agentlink.attachEvent("OnLoadOfflineVoiceMailHistoryDone", fctHandler);
*/
this.OnLoadOfflineVoiceMailHistoryDone = "";
/**
Fired when the email information requested by function {@link AgentLinkClass#HistoryLoadOfflineMailHistory} has been loaded
@event
@param {MailSimpleInformations} mailInfo - The historized email informations
@param {string} askKey - Webservice call identifier (for managing more than one request at a time)
@param {boolean} withInitialMessage - True if the history can contains the origin message (on email context session, no on email sended on another context)
@example
var fctHandler = function(mailInfo, askKey, withInitialMessage) {
Log("MyLogger", "DEBUG", "Email loaded from history. Uid:" + mailInfo.MailUid);
}
agentlink.attachEvent("OnLoadOfflineMailHistoryDone", fctHandler);
*/
this.OnLoadOfflineMailHistoryDone = "";
/**
Fired when the fax requested by function {@link AgentLinkClass#HistoryLoadOfflineFaxHistory} has been loaded
@event
@param {FaxSimpleInformations} faxInfo - The historized fax informations
@param {string} askKey - Webservice call identifier (for managing more than one request at a time)
@example
var fctHandler = function(faxInfo, askKey) {
Log("MyLogger", "DEBUG", "Fax loaded from history. Uid:" + faxInfo.FaxUid);
}
agentlink.attachEvent("OnLoadOfflineFaxHistoryDone", fctHandler);
*/
this.OnLoadOfflineFaxHistoryDone = "";
/**
Fired when the socialnetwork feed requested by function {@link AgentLinkClass#HistoryLoadOfflineSocialNetworkHistory} has been loaded
@event
@param {SocialNetworkInformation} snInfo - The historized social network informations
@param {string} askKey - Webservice call identifier (for managing more than one request at a time)
@example
var fctHandler = function(socialNetworkInfos, askKey) {
Log("MyLogger", "DEBUG", "SocialNetwork informations loaded from history. Uid:" + faxInfo.FaxUid);
}
agentlink.attachEvent("OnLoadOfflineSocialNetworkHistoryDone", fctHandler);
*/
this.OnLoadOfflineSocialNetworkHistoryDone = "";
/**
When an error occur on CRM webservice
No Adress book informations will be available
@event
@param {number} statusCode - error code
@param {string} statusText - textual reason for the error
*/
this.OnCrmWsError = "";
/**
When an error occur on History webservice
No history informations will be available
@event
@param {number} statusCode - error code
@param {string} statusText - textual reason for the error
*/
this.OnHistoryWsError = "";
/**
When the ignore command sended to mediaserver for SocialNetwork is done.
This command is managed asynchronously.
@event
@param {ContextTypes} contextType - contextType on which the event is fired. Only SocialNetwork and Email for now.
*/
this.OnIgnoreMessageDone = "";
/**
When the RecordSign StarSign method has been executed.
This command is managed asynchronously
@event
@param {string} guid : the GUID of the initial caller
@param {string} state : contains OK or KO depending of the result
@param {number} code : the result code when there is error
*/
this.OnRecordSignStartSignResult = "";
/**
When the RecordSign OTP method has been executed.
This command is managed asynchronously
@event
@param {string} guid : the GUID of the initial caller
@param {string} state : contains OK or KO depending of the result
@param {number} code : the result code when there is error
*/
this.OnRecordSignOTPResult = "";
/**
When Additional consult data (for a transfered session from another context type) are received for a session
@event
@param {ContextTypes} contextType - contextType on which the event is fired.
@param {string} sessionId - session id on which the event is fired.
@param {Object} consultData - the data of the consulted or transfered session.
*/
this.OnAdditionalConsultDataReceived = "";
}
AgentLinkClass.prototype = {
/**
* Used to listen a particular event.
* @param {string} event - the event name to listen
* @param {function} handler - the javascript function handler to call when the event is fired
* @example
* var fctHandler = function(connected) {
* Log("MyLogger", "DEBUG", "connected");
* }
* agentlink.attachEvent("OnConnect", fctHandler);
*/
attachEvent: function(event, handler) {
if (!this._events[event]) {
this._events[event] = new Array();
}
this._events[event].push(handler);
},
/** @private */
Send : function(key, obj) {
if (!obj) obj = {};
try {
if (this._isFlashPlayer) {
this.getFL().Send(key, obj);
} else {
AX_Websock_Send(key, obj);
}
} catch (e) {
if (this.Connected) {
Log("AGTLNK_JS", "ERROR", "Error sending " + key + " - Connection has been lost");
this.Connected = false;
}
}
},
/**
* Connect to the CTIProxy.<br>
* Will fire the "OnConnect" event
* @returns true if AgentLink isn't already connected
*/
Connect: function() {
try
{
if (this._connecting == true) {
Log("AGTLNK_JS", "DEBUG", "Connection in progress. Skip this request !");
return;
}
if (this.Connected == true) {
Log("AGTLNK_JS", "DEBUG", "Connection already established. Skip this request !");
return;
}
this._timeoutConnect = setTimeout(ConnectTimeout, 10000);
this._emitOnConnectionStart();
Log("AGTLNK_JS", "INFO", "Connect to : " + this.AgentProxy + ":" + this.Port);
if (this._isFlashPlayer) {
this.getFL().Connect(this.AgentProxy, this.Port);
} else {
if (this._websocket != null) {
this._websocket.onopen = null;
this._websocket.onmessage = null;
this._websocket.onclose = null;
this._websocket.onerror = null;
this._websocket = null;
}
this._websocket = new WebSocket(this._wsProto + "://" + this.AgentProxy + ":" + this._wsPort + "/" + this.CustomerId);
this._websocket.onopen = AX_Websock_OnOpen;
this._websocket.onmessage = AX_Websock_OnMessage;
this._websocket.onclose = AX_Websock_OnClose;
this._websocket.onerror = AX_Websock_OnError;
if (window.allSockets) {
window.allSockets.push(this._websocket);
} else {
window.allSockets = []
window.allSockets.push(this._websocket);
}