TSLib javascript library

TSLib is a javascript library, built on top of the TelServices protocol, that enables you to control your PBX phone from a web page.

  • handles the link to TelServer including the redundancy if it is configured
  • high level API (handling the TelServices protocol encoding/decoding)

Insertion into web page

<head>
<script type="text/javascript" src="/TSLib/TSLib-bundle.js"></script>
<script type="text/javascript" src="/TSLib/TSLib-config.js"></script>
</head>

Configuration

It is limited to providing address of TelServer in the file "TSLib-config.js".

unigone_config = {
TELSERVICES_TELSERVER_URL: "http://telserver.mycompany.com:8082"
};

If TelServer is redundant, a second address can be defined.

 

Supervision of the extension

It is achieved thanks to the object 'context':

var context = unigone.TSLib.context.getContext();

Supervision of extension '801':

context.activateService("openSession", {
deviceNumber: "801"
});

Calls

Make a call to extension '802':

context.activateService("makeCall", {
calledPartyNumber: "802"
});

Answer the call:

context.activateService("answerCall"); 

Agent status management

context.activateService("agentState", {
state: "ready"
});

Events reception

Call events:

context.addListener({ 
originatedCall: function(simpleCallEvent) { console.log('outgoing call to: '+simpleCallEvent.otherParty.number) },
incomingCall: function(simpleCallEvent) { console.log('incoming call from: '+simpleCallEvent.otherParty.number); },
clearedCall: function(simpleCallEvent) { console.log('end of call with: '+simpleCallEvent.otherParty.number) }
});

Session events:

context.addListener({
sessionChange: function(sessionEvent) { console.log('admin state: '+sessionEvent.state+';operational state: '+sessionEvent.operational); }
});