Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

The Subscribe method allows you to monitor extension for events such as:

  • Answer
  • Hangup
  • Dial
  • Connected
  • Ringing

The Subscrive uses a long poll method. After receiving a 'subscribe' request the server will wait upto "timeout" seconds for call 14.0 Events on the target extension(s).

The method will return as soon as any events occurs on one of the target extensions or when the timeout occurs.

To guarentee that you don't miss any events between calls to subscribe you use the 'seq' data returned by a call to subscribe as the value of lastSequenceNumber in the next call to subscribe. 

This method can immeditately return the current state of all requested extensions, use timeout=0 and lastSequenceNumber=0. There is actually a minimum poll period of around 100ms.

A single subscribe method will often return multiple events.

Entry point:

http://<server host>/servicemanager/rest/CallManagementAPI/subscribe

Parameters (case sensitive):

exten - a comma-separated list of extensions to monitor for calls.

instanceId - Not used.

lastSequenceNumber - The client should retrieve this number from the CallData.seq value in the API response.
 
timeOut - the poll timeout in seconds - default is 10 if this parameter is omitted.

timeStamp - the authentication timestamp.
 
hash - the authentication signature or hash.
 
This API call returns a CallData resource containing the information needed to correctly handle any call.
 
Sample response when two calls are received from 400 at extension 410. The first call arrives and the API returns, then the second call arrives and the API returns the information about the second call only. Both of the calls are rejected simultaneously and the final reponse contains a Data resource with a collection of Extension resources (e.g. 400 in the sampe below). Each Extension resource contains an array of CallData resources.  The associated uniqueCallId is used to asnwer a call (see below).
  
  
http://127.0.0.1:8080/servicemanager/rest/CallManagementAPI/subscribe?timeOut=60&timeStamp=1412749504522&hash=10e371546ab11a5910cb762837060a21c7086cb5087aa69bc79b7093a645ef14&lastSequenceNumber=28&instanceId=1&exten=400,410,410
 
{"Data":{ 
"410":[{"CallData":{     
    "canAnswer":true,     
    "callerId":"400",     
    "uniqueCallId":"1412750652.496",     
    "callStartTime":"",     
    "isQueueCall":false,     
    "isClickToDialCall":false,     
    "inbound":true,     
    "status":"Ringing"},"CallID":10,"Code":0}], 
"400":[{"CallData":{     
    "canAnswer":false,     
    "callerId":"",     
    "uniqueCallId":"1412750656.497",     
    "callStartTime":"",     
    "isQueueCall":false,     
    "isClickToDialCall":false,     
    "inbound":false,     
    "status":"Dialing Out"},"CallID":9,"Code":0}]},"seq":32,"Code":0}
http://127.0.0.1:8080/servicemanager/rest/CallManagementAPI/subscribe?timeOut=60&timeStamp=1412749504522&hash=10e371546ab11a5910cb762837060a21c7086cb5087aa69bc79b7093a645ef14&lastSequenceNumber=32&instanceId=1&exten=400,410,410
 
{"Data":{ 
"410":[{"CallData":{     
    "canAnswer":true,     
    "callerId":"400",     
    "uniqueCallId":"1412750658.498",     
    "callStartTime":"",     
    "isQueueCall":false,         
    "isClickToDialCall":false,     
    "inbound":true,     
    "status":"Ringing"},"CallID":12,"Code":0}], 
"400":[{"CallData":{     
    "canAnswer":false,     
    "callerId":"",     
    "uniqueCallId":"1412750661.499",     
    "callStartTime":"",     
    "isQueueCall":false,     
    "isClickToDialCall":false,     
    "inbound":false,     
    "status":"Dialing Out"},"CallID":11,"Code":0}]},"seq":36,"Code":0}
http://127.0.0.1:8080/servicemanager/rest/CallManagementAPI/subscribe?timeOut=60&timeStamp=1412749504522&hash=10e371546ab11a5910cb762837060a21c7086cb5087aa69bc79b7093a645ef14&lastSequenceNumber=36&instanceId=1&exten=400,410,410
 
{"Data":{ 
"410":[{"CallData":{     
    "canAnswer":false,     
    "callerId":"400",     
    "uniqueCallId":"1412750652.496",     
    "callStartTime":"",     
    "isQueueCall":false,     
    "isClickToDialCall":false,     
    "inbound":true,     
    "status":"Hungup",     
    "hangupCause":"NO_ANSWER"},"CallID":10,"Code":0}, 
{"CallData":{     
    "canAnswer":false,     
    "callerId":"400",     
    "uniqueCallId":"1412750658.498",     
    "callStartTime":"",     
    "isQueueCall":false,     
    "isClickToDialCall":false,     
    "inbound":true,     
    "status":"Hungup",     
    "hangupCause":"NO_ANSWER"},"CallID":12,"Code":0}], 
"400":[{"CallData":{     
    "canAnswer":false,     
    "callerId":"410",     
    "uniqueCallId":"1412750656.497",     
    "callStartTime":"",     
    "isQueueCall":false,     
    "isClickToDialCall":false,     
    "inbound":false,     
    "status":"Hungup",     
    "hangupCause":"NO_ANSWER"},"CallID":9,"Code":0}, 
{"CallData":{     
    "canAnswer":false,     
    "callerId":"410",     
    "uniqueCallId":"1412750661.499",     
    "callStartTime":"",     
    "isQueueCall":false,     
    "isClickToDialCall":false,     
    "inbound":false,     
    "status":"Hungup",     
    "hangupCause":"NO_ANSWER"},"CallID":11,"Code":0}]},"seq":40,"Code":0}
 

 

    

 
To answer the first call listed in the sample above use the uniqueCallId and pass it in as the uniqueId to the answer method: 
answer?answerString=...&timeStamp=...&hash=....&exten=101&uniqueId=1403148776.566
 
The CallData values are defined as follows:
canAnswer true if an incoming call has been detected, is not yet answered and is not from a queue, false otherwise.
callerId the caller ID incoming or outgoing call
seq the sequence number of the subscribe call. This number is used to determine which calls should be shown in the response. To get the current state of all calls always use 0, other wise only calls where the status has changed since "seq" will be retrieved.
uniqueCallId an internal unique ID for the call. Use this ID in the call to 06.0 Answer.
isQueueCall true if the call is received through a queue, false otherwise
isClickToDialCall true if the call was initaited by Click-to-Dial; false otherwise.
inbound true if an inbound call is detected; false otherwise.
status the status of the monitored handset - one of: Dialing Out, Connected, Ringing or Hungup
hangupCause If the call didn't connect and is Hungup, the cause will be one of DISCONNECTED, NO_ANSWER, CONGESTION or BUSY

Sample API call sequence - one extension answered multiple times:

Call 1: Extension 400 dials extension 410, then the call is answered and finally hungup.
 
  
http://127.0.0.1:8080/servicemanager/rest/CallManagementAPI/subscribe?timeOut=60&timeStamp=1412749504522&hash=10e371546ab11a5910cb762837060a21c7086cb5087aa69bc79b7093a645ef14&lastSequenceNumber=0&instanceId=1&exten=400,410,410 {"Data":{
"410": [{"CallData":{
     "canAnswer":true,
     "callerId":"400",
     "uniqueCallId":"1412749510.488",
     "callStartTime":"",
     "isQueueCall":false,
     "isClickToDialCall":false,
     "inbound":true,
     "status":"Ringing"},"CallID":2,"Code":0}], 
"400": [{"CallData":{     
    "canAnswer":false,     
    "callerId":"",     
    "uniqueCallId":"1412749517.489",     
    "callStartTime":"",     
    "isQueueCall":false,     
    "isClickToDialCall":false,     
    "inbound":false,     
    "status":"Dialing Out"} ,"CallID":1,"Code":0}]},"seq":4,"Code":0}
http://127.0.0.1:8080/servicemanager/rest/CallManagementAPI/subscribe?timeOut=60&timeStamp=1412749504522&hash=10e371546ab11a5910cb762837060a21c7086cb5087aa69bc79b7093a645ef14&lastSequenceNumber=4&instanceId=1&exten=400,410,410
 
{"Data":{ 
"410": [{"CallData":{
     "canAnswer":false,     
     "callerId":"400",     
     "uniqueCallId":"1412749510.488",     
     "callStartTime":"2014/10/08 17:25:18",     
     "isQueueCall":false,     
     "isClickToDialCall":false,     
     "inbound":true,     
     "status":"Connected"},"CallID":2,"Code":0}], 
"400": [{"CallData":{     
    "canAnswer":false,     
    "callerId":"410",     
    "uniqueCallId":"1412749517.489",     
    "callStartTime":"2014/10/08 17:25:18",     
    "isQueueCall":false,     
    "isClickToDialCall":false,     
    "inbound":false,     
    "status":"Connected"},"CallID":1,"Code":0}]},"seq":6,"Code":0}
http://127.0.0.1:8080/servicemanager/rest/CallManagementAPI/subscribe?timeOut=60&timeStamp=1412749504522&hash=10e371546ab11a5910cb762837060a21c7086cb5087aa69bc79b7093a645ef14&lastSequenceNumber=6&instanceId=1&exten=400,410,410
 
{"Data":{ 
"410": [{"CallData":{     
    "canAnswer":false,     
    "callerId":"400",     
    "uniqueCallId":"1412749510.488",     
    "callStartTime":"2014/10/08 17:25:18",     
    "isQueueCall":false,     
    "isClickToDialCall":false,     
    "inbound":true,     
    "status":"Hungup"},"CallID":2,"Code":0}], 
"400": [{"CallData":{     
    "canAnswer":false,     
    "callerId":"410",     
    "uniqueCallId":"1412749517.489",     
    "callStartTime":"2014/10/08 17:25:18",     
    "isQueueCall":false,     
    "isClickToDialCall":false,     
    "inbound":false,     
    "status":"Hungup"},"CallID":1,"Code":0}]},"seq":10,"Code":0}
 

 

Call 2: Extension 400 dials extension 410, 410 is busy.
http://127.0.0.1:8080/servicemanager/rest/CallManagementAPI/subscribe?timeOut=60&timeStamp=1412749504522&hash=10e371546ab11a5910cb762837060a21c7086cb5087aa69bc79b7093a645ef14&lastSequenceNumber=10&instanceId=1&exten=400,410,410

{"Data":{
"410":[{"CallData":{
    "canAnswer":true,
    "callerId":"400",
    "uniqueCallId":"1412749905.490",
    "callStartTime":"",
    "isQueueCall":false,
    "isClickToDialCall":false,
    "inbound":true,
    "status":"Ringing"},"CallID":4,"Code":0}],
"400":[{"CallData":{
    "canAnswer":false,
    "callerId":"",
    "uniqueCallId":"1412749908.491",
    "callStartTime":"",
    "isQueueCall":false,
    "isClickToDialCall":false,
    "inbound":false,
    "status":"Dialing Out"},"CallID":3,"Code":0}]},"seq":14,"Code":0}


http://127.0.0.1:8080/servicemanager/rest/CallManagementAPI/subscribe?timeOut=60&timeStamp=1412749504522&hash=10e371546ab11a5910cb762837060a21c7086cb5087aa69bc79b7093a645ef14&lastSequenceNumber=14&instanceId=1&exten=400,410,410

{"Data":{
"410":[{"CallData":{
    "canAnswer":false,
    "callerId":"400",
    "uniqueCallId":"1412749905.490",
    "callStartTime":"",
    "isQueueCall":false,
    "isClickToDialCall":false,
    "inbound":true,
    "status":"Hungup",
    "hangupCause":"BUSY"},"CallID":4,"Code":0}],
"400":[{"CallData":{
    "canAnswer":false,
    "callerId":"410",
    "uniqueCallId":"1412749908.491",
    "callStartTime":"",
    "isQueueCall":false,
    "isClickToDialCall":false,
    "inbound":false,
    "status":"Hungup",
    "hangupCause":"BUSY"},"CallID":3,"Code":0}]},"seq":16,"Code":0}

  • No labels