Jump to: navigation, search

SwapCalls

This operation is part of the Voice API section of the Web Services API.

Overview

Swaps between two calls when one call is held and the other is established.

Request URL /api/v2/me/calls/{id}
HTTP method POST
Required features api-voice

Parameters

Parameter Value
operationName SwapCalls
otherCallUri The URI of the call to swap.

Sample 1

Request

POST api/v2/me/calls/013V08JRL498H1OI04000VTAES00000S
{
  "operationName": "SwapCalls",
  "otherCallUri": "http://127.0.0.1:8080/api/v2/me/calls/01RCC3N118B1V0SL8O7GK2LAES00000P"
}

HTTP response

{
  "statusCode": 0
}

CometD notification

The SwapCalls operations results in two notifications. One for the call that is placed on hold, and a second for the held call is retrieved.

{  
   "data":{  
      "notificationType":"StatusChange",
      "call":{  
         "id":"01RCC3N118B1V0SL8O7GK2LAES00000P",
         "state":"Established",
         "callUuid":"01RCC3N118B1V0SL8O7GK2LAES00000P",
         "connId":"0071027198180019",
         "deviceUri":"http://127.0.0.1:8080/api/v2/devices/631608b3-ceb1-472b-ba05-2ae39555b0d1",
         "participants":[  
            {  
               "e164Number":"",
               "formattedPhoneNumber":"15001",
               "phoneNumber":"15001",
               "digits":"15001"
            }
         ],
         "dnis":"15001",
         "callType":"Internal",
         "capabilities":[  
            "UpdateUserData",
            "SendDtmf",
            "SwapCalls",
            "InitiateConference",
            "Hold",
            "SingleStepTransfer",
            "InitiateTransfer",
            "AttachUserData",
            "CompleteConference",
            "DeleteUserDataPair",
            "SingleStepConference",
            "DeleteUserData",
            "Hangup",
            "CompleteTransfer"
         ],
         "duration":"156",
         "mute":"Off",
         "supervisorListeningIn":false,
         "monitoredUserMuted":false,
         "monitoring":false,
         "uri":"http://127.0.0.1:8080/api/v2/me/calls/01RCC3N118B1V0SL8O7GK2LAES00000P",
         "path":"/calls/01RCC3N118B1V0SL8O7GK2LAES00000P"
      },
      "phoneNumber":"15000",
      "extensions":{  
         "BusinessCall":0
      },
      "messageType":"CallStateChangeMessage"
   },
   "channel":"/v2/me/calls"
}
{  
   "data":{  
      "notificationType":"StatusChange",
      "call":{  
         "id":"01RCC3N118B1V0SL8O7GK2LAES00000Q",
         "state":"Held",
         "callUuid":"01RCC3N118B1V0SL8O7GK2LAES00000Q",
         "connId":"007102719818001a",
         "deviceUri":"http://127.0.0.1:8080/api/v2/devices/631608b3-ceb1-472b-ba05-2ae39555b0d1",
         "participants":[  
            {  
               "e164Number":"",
               "formattedPhoneNumber":"15002",
               "phoneNumber":"15002",
               "digits":"15002"
            }
         ],
         "dnis":"15002",
         "callType":"Consult",
         "capabilities":[  
            "UpdateUserData",
            "SendDtmf",
            "SwapCalls",
            "InitiateConference",
            "Hold",
            "SingleStepTransfer",
            "InitiateTransfer",
            "AttachUserData",
            "CompleteConference",
            "DeleteUserDataPair",
            "SingleStepConference",
            "DeleteUserData",
            "Hangup",
            "CompleteTransfer"
         ],
         "duration":"129",
         "mute":"Off",
         "supervisorListeningIn":false,
         "monitoredUserMuted":false,
         "monitoring":false,
         "uri":"http://127.0.0.1:8080/api/v2/me/calls/01RCC3N118B1V0SL8O7GK2LAES00000Q",
         "path":"/calls/01RCC3N118B1V0SL8O7GK2LAES00000Q"
      },
      "phoneNumber":"15000",
      "messageType":"CallStateChangeMessage"
   },
   "channel":"/v2/me/calls"
}

Sample 2

The following examples describe the full set of requests and events that demonstrate using the SwapCalls operation.

The agent receives a notification of an inbound call:

{  
   "data":{  
      "notificationType":"StatusChange",
      "call":{  
         "id":"013V08JRL498H1OI04000VTAES00000R",
         "state":"Ringing",
         "callUuid":"013V08JRL498H1OI04000VTAES00000R",
         "connId":"0071023821aec01b",
         "deviceUri":"http://127.0.0.1:8080/api/v2/devices/efe1ab32-53f9-43ce-b65e-5768c61f7d4a",
         "participants":[  
            {  
               "e164Number":"",
               "formattedPhoneNumber":"5000",
               "phoneNumber":"5000",
               "digits":"5000"
            }
         ],
         "dnis":"5005",
         "callType":"Internal",
         "capabilities":[  
            "Answer",
            "DeleteUserDataPair",
            "AttachUserData",
            "DeleteUserData",
            "UpdateUserData"
         ],
         "duration":"0",
         "mute":"Off",
         "supervisorListeningIn":false,
         "monitoredUserMuted":false,
         "uri":"http://127.0.0.1:8080/api/v2/me/calls/013V08JRL498H1OI04000VTAES00000R",
         "path":"/calls/013V08JRL498H1OI04000VTAES00000R"
      },
      "phoneNumber":"5005",
      "extensions":{  
         "WrapUpTime":0,
         "BusinessCall":0
      },
      "messageType":"CallStateChangeMessage"
   },
   "channel":"/v2/me/calls"
}

The agent answers the inbound call and receives notification of the call state change:

{  
   "data":{  
      "notificationType":"StatusChange",
      "call":{  
         "id":"013V08JRL498H1OI04000VTAES00000R",
         "state":"Established",
         "callUuid":"013V08JRL498H1OI04000VTAES00000R",
         "connId":"0071023821aec01b",
         "deviceUri":"http://127.0.0.1:8080/api/v2/devices/efe1ab32-53f9-43ce-b65e-5768c61f7d4a",
         "participants":[  
            {  
               "e164Number":"",
               "formattedPhoneNumber":"5000",
               "phoneNumber":"5000",
               "digits":"5000"
            }
         ],
         "dnis":"5005",
         "callType":"Internal",
         "capabilities":[  
            "DeleteUserDataPair",
            "AttachUserData",
            "Hangup",
            "DeleteUserData",
            "Hold",
            "SendDtmf",
            "InitiateConference",
            "InitiateTransfer",
            "SingleStepConference",
            "UpdateUserData",
            "SingleStepTransfer"
         ],
         "duration":"5",
         "mute":"Off",
         "supervisorListeningIn":false,
         "monitoredUserMuted":false,
         "uri":"http://127.0.0.1:8080/api/v2/me/calls/013V08JRL498H1OI04000VTAES00000R",
         "path":"calls/013V08JRL498H1OI04000VTAES00000R"
      },
      "phoneNumber":"5005",
      "extensions":{  
         "WrapUpTime":0,
         "BusinessCall":0
      },
      "messageType":"CallStateChangeMessage"
   },
   "channel":"/v2/me/calls"
}

The agent requests the inbound call be placed on hold:

POST api/v2/me/calls/013V08JRL498H1OI04000VTAES00000R
{
  "operationName": "Hold"
}

Notification is received of the call being held:

{  
   "data":{  
      "notificationType":"StatusChange",
      "call":{  
         "id":"013V08JRL498H1OI04000VTAES00000R",
         "state":"Held",
         "callUuid":"013V08JRL498H1OI04000VTAES00000R",
         "connId":"0071023821aec01b",
         "deviceUri":"http://127.0.0.1:8080/api/v2/devices/efe1ab32-53f9-43ce-b65e-5768c61f7d4a",
         "participants":[  
            {  
               "e164Number":"",
               "formattedPhoneNumber":"5000",
               "phoneNumber":"5000",
               "digits":"5000"
            }
         ],
         "dnis":"5005",
         "callType":"Internal",
         "capabilities":[  
            "Retrieve",
            "DeleteUserDataPair",
            "AttachUserData",
            "Hangup",
            "DeleteUserData",
            "InitiateConference",
            "InitiateTransfer",
            "SingleStepConference",
            "UpdateUserData",
            "SingleStepTransfer"
         ],
         "duration":"10",
         "mute":"Off",
         "supervisorListeningIn":false,
         "monitoredUserMuted":false,
         "uri":"http://127.0.0.1:8080/api/v2/me/calls/013V08JRL498H1OI04000VTAES00000R",
         "path":"/calls/013V08JRL498H1OI04000VTAES00000R"
      },
      "phoneNumber":"5005",
      "extensions":{  
         "WrapUpTime":0,
         "BusinessCall":0
      },
      "messageType":"CallStateChangeMessage"
   },
   "channel":"/v2/me/calls"
}

The agent requests the second call be made:

POST api/v2/me/devices/efe1ab32-53f9-43ce-b65e-5768c61f7d4a/calls
{
  "operationName": "Dial",
  "destination": {
    "phoneNumber": "5001"
  }
}

The agent receives notification that the second call is dialing:

{  
   "data":{  
      "notificationType":"StatusChange",
      "call":{  
         "id":"013V08JRL498H1OI04000VTAES00000S",
         "state":"Dialing",
         "callUuid":"013V08JRL498H1OI04000VTAES00000S",
         "connId":"0071023821aec01c",
         "deviceUri":"http://127.0.0.1:8080/api/v2/devices/efe1ab32-53f9-43ce-b65e-5768c61f7d4a",
         "participants":[  
            {  
               "e164Number":"",
               "formattedPhoneNumber":"5001",
               "phoneNumber":"5001",
               "digits":"5001"
            }
         ],
         "dnis":"5001",
         "callType":"Internal",
         "capabilities":[  
            "DeleteUserDataPair",
            "AttachUserData",
            "Hangup",
            "DeleteUserData",
            "SendDtmf",
            "SwapCalls",
            "UpdateUserData",
            "CompleteTransfer"
         ],
         "duration":"0",
         "mute":"Off",
         "supervisorListeningIn":false,
         "monitoredUserMuted":false,
         "uri":"http://127.0.0.1:8080/api/v2/me/calls/013V08JRL498H1OI04000VTAES00000S",
         "path":"/calls/013V08JRL498H1OI04000VTAES00000S"
      },
      "phoneNumber":"5005",
      "extensions":{  
         "WrapUpTime":0,
         "BusinessCall":0
      },
      "messageType":"CallStateChangeMessage"
   },
   "channel":"/v2/me/calls"
}

and then notification that the second call is answered:

{  
   "data":{  
      "notificationType":"StatusChange",
      "call":{  
         "id":"013V08JRL498H1OI04000VTAES00000S",
         "state":"Established",
         "callUuid":"013V08JRL498H1OI04000VTAES00000S",
         "connId":"0071023821aec01c",
         "deviceUri":"http://127.0.0.1:8080/api/v2/devices/efe1ab32-53f9-43ce-b65e-5768c61f7d4a",
         "participants":[  
            {  
               "e164Number":"",
               "formattedPhoneNumber":"5001",
               "phoneNumber":"5001",
               "digits":"5001"
            }
         ],
         "dnis":"5001",
         "callType":"Internal",
         "capabilities":[  
            "DeleteUserDataPair",
            "AttachUserData",
            "Hangup",
            "DeleteUserData",
            "Hold",
            "SendDtmf",
            "InitiateConference",
            "SwapCalls",
            "InitiateTransfer",
            "SingleStepConference",
            "UpdateUserData",
            "SingleStepTransfer",
            "CompleteTransfer",
            "CompleteConference"
         ],
         "duration":"10",
         "mute":"Off",
         "supervisorListeningIn":false,
         "monitoredUserMuted":false,
         "uri":"http://127.0.0.1:8080/api/v2/me/calls/013V08JRL498H1OI04000VTAES00000S",
         "path":"/calls/013V08JRL498H1OI04000VTAES00000S"
      },
      "phoneNumber":"5005",
      "extensions":{  
         "WrapUpTime":0,
         "BusinessCall":0
      },
      "messageType":"CallStateChangeMessage"
   },
   "channel":"/v2/me/calls"
}

The agent then sends the SwapCalls request:

POST api/v2/me/calls/013V08JRL498H1OI04000VTAES00000S
{
  "operationName": "SwapCalls",
  "otherCallUri": "http://localhost:8080/api/v2/me/calls/013V08JRL498H1OI04000VTAES00000R"
}

The agent then receives notification that the second call is now held:

{  
   "data":{  
      "notificationType":"StatusChange",
      "call":{  
         "id":"013V08JRL498H1OI04000VTAES00000S",
         "state":"Held",
         "callUuid":"013V08JRL498H1OI04000VTAES00000S",
         "connId":"0071023821aec01c",
         "deviceUri":"http://127.0.0.1:8080/api/v2/devices/efe1ab32-53f9-43ce-b65e-5768c61f7d4a",
         "participants":[  
            {  
               "e164Number":"",
               "formattedPhoneNumber":"5001",
               "phoneNumber":"5001",
               "digits":"5001"
            }
         ],
         "dnis":"5001",
         "callType":"Internal",
         "capabilities":[  
            "Retrieve",
            "DeleteUserDataPair",
            "AttachUserData",
            "Hangup",
            "DeleteUserData",
            "InitiateConference",
            "InitiateTransfer",
            "SingleStepConference",
            "UpdateUserData",
            "SingleStepTransfer"
         ],
         "duration":"41",
         "mute":"Off",
         "supervisorListeningIn":false,
         "monitoredUserMuted":false,
         "uri":"http://127.0.0.1:8080/api/v2/me/calls/013V08JRL498H1OI04000VTAES00000S",
         "path":"/calls/013V08JRL498H1OI04000VTAES00000S"
      },
      "phoneNumber":"5005",
      "extensions":{  
         "WrapUpTime":0,
         "BusinessCall":0
      },
      "messageType":"CallStateChangeMessage"
   },
   "channel":"/v2/me/calls"
}

and to complete the operation, a notification that the first call is now be retrieved from hold:

{  
   "data":{  
      "notificationType":"StatusChange",
      "call":{  
         "id":"013V08JRL498H1OI04000VTAES00000R",
         "state":"Established",
         "callUuid":"013V08JRL498H1OI04000VTAES00000R",
         "connId":"0071023821aec01b",
         "deviceUri":"http://127.0.0.1:8080/api/v2/devices/efe1ab32-53f9-43ce-b65e-5768c61f7d4a",
         "participants":[  
            {  
               "e164Number":"",
               "formattedPhoneNumber":"5000",
               "phoneNumber":"5000",
               "digits":"5000"
            }
         ],
         "dnis":"5005",
         "callType":"Internal",
         "capabilities":[  
            "DeleteUserDataPair",
            "AttachUserData",
            "Hangup",
            "DeleteUserData",
            "Hold",
            "SendDtmf",
            "InitiateConference",
            "SwapCalls",
            "InitiateTransfer",
            "SingleStepConference",
            "UpdateUserData",
            "SingleStepTransfer",
            "CompleteTransfer",
            "CompleteConference"
         ],
         "duration":"60",
         "mute":"Off",
         "supervisorListeningIn":false,
         "monitoredUserMuted":false,
         "uri":"http://127.0.0.1:8080/api/v2/me/calls/013V08JRL498H1OI04000VTAES00000R",
         "path":"/calls/013V08JRL498H1OI04000VTAES00000R"
      },
      "phoneNumber":"5005",
      "extensions":{  
         "WrapUpTime":0,
         "BusinessCall":0
      },
      "messageType":"CallStateChangeMessage"
   },
   "channel":"/v2/me/calls"
}

Feedback

Comment on this article:

blog comments powered by Disqus
This page was last modified on March 25, 2016, at 10:22.