API Dialplan

Servetel offers Number Masking feature which allows two parties to communicate over an intermediate number, thereby preventing either party from knowing other's phone numbers.

Number Masking can be used by configuring HTTP Method, URL, Request body and a Failover Destination.

Request Variables

When a call is received on our server, the below data is sent to the customer’s API that was specified during API dialplan configuration.

📘

Kindly contact Servetel support team to enable API Dialplan on Servetel portal for your account.

Variable NameDescriptionFormatData Type
$uuidUnique ID of the call-String
$call_to_numberDialed number-String
$caller_id_numberCaller numberCountry code followed by caller numberString
$start_stampStart time of the callYYYY-mm-dd HH:mm:ss
(For example - 2019-12-02 00:00:00)
String
$last_dtmfDTMF inputs received-Array
$call_flowCall flow executed-Array of objects

In return, we expect a response in the below format

🚧

In case of any kind of failure in receiving an appropriate response from API, the action selected in the Failover destination field will be executed.

[
  {
    "recording": {
      "type": "system",
      "data": 7611,
      "dtmf":{
        "timeout": 6000,
        "maxLength" : 4
      }
    }
  },
  {
    "recording": {
      "type": "url",
      "data": "http://sample_url.com/abcxy/214/032b32463.mp3"
    }
  },
  {
    "transfer": {
      "type": "number",
      "data": 9876543210
    }
  },
  {
    "transfer": {
      "type": "agent",
      "data": "50746745"
    }
  }
]

The response from API will describe the series of actions to be performed, there are two acceptable keys: recording and transfer, containing information about the source of recording and where the call is to be transferred respectively.
In the given sample response, the two recordings will be played sequentially and the call will be transferred to the given number and agent afterwards.

Response Variables

Below are the expected response variables.

Variable NameDescriptionData Type
recordingRequired if playing recording is the action to be performedObject
transferRequired if call transfer is the action to be performedObject
api_dialplanRequired if another API Dial plan is to be executed as actionObject

Recording

recording object has below two properties

Variable NameDescriptionData TypeField Type
typeSource of recordingStringRequired
dataData required for recording to be played (example: unique ID of recording, url of recording)StringRequired
dtmfIf a DTMF is needed over recordingObjectOptional
[{
	"recording": {
		"type": "system",
		"data": 1234,
		"dtmf": {
			"timeout": 6000,
			"maxLength": 4,
			"retry": 2
		}
	}
}]

type can be one of the below fields

Variable NameDescriptionData Type
systemRequired if source of recording is the recording present in the servetel's web portalString
urlRequired if source of recording is an external urlString

dtmf object can have following 3 properties

Variable NameDescriptionField TypeField Type
timeoutDigit timeout while entering DTMF, to be provided in MillisecondsIntegerOptional
maxLengthMaximum length of input to be capturedIntegerOptional
retryNumber of retries to take input over recording in case of timeoutIntegerOptional

📘

If these keys are not provided, by default, 5000, 10 and 0 will be used for timeout, maxLength and retry, respectively. Maximum number of allowed retries is 5.

Transfer

transfer object has below two properties

Variable NameDescriptionData TypeField Type
typeDestination for transfer
(Available transfer types are discussed in next section)
StringRequired
dataNumber or ID for destination depending on transfer typeArray/StringRequired
ring_typeRing strategy in case of multiple numbers/agents in number/agent/intercom transfer types
Can have one of the following values :
1. order_by
2. simultaneous
StringOptional
[{
	"transfer": {
		"type": "agent",
		"data": ["12345", "23456", "34567"],
		"ring_type": "order_by"
	}
}]

Refer following table for available transfer types and information on their corresponding data fields

Variable NameDescriptionData Type
numberRequired if call is to be transferred to one or more mobile numbersArray of 10 digit mobile number(s)
agentRequired if call is to be transferred to one or more agentsArray of agent ID(s)
intercomRequired if call is to be transferred to one or more agents using their intercomArray of intercom of agent(s)
departmentRequired if call is to be transferred to a department,
ID of Department to be provided in data key
String
ivrRequired if call is to be transferred to an IVR,
ID of IVR to be provided in data key
String
auto_attendantRequired if call is to be transferred to an auto attendant,
ID of Auto Attendant to be provided in data key
String

API Dialplan (api_dialplan)

This object has following property

Variable NameDescriptionData Type
dataID of API Dial plan to be executed
This ID can be found on edit API Dial plan page
String
[{
	"api_dialplan": {
		"data": "sample_api_dialplan_id123ab"
	}
}]

📘

Up to 3 API dial plans can be nested at a time

👍

Upcoming Features in API Dial plan

Soon, individual retries on invalid input and timeout, recordings to be played on invalid input and timeout, recordings for prompting for retry and destinations for both these cases, minLength of input, and destinations over specific inputs could be configured on API dial plan as well. With this update, the DTMF object in recording action will look like the example given below.

[{
	"dtmf": {
		"maxLength": 5,
		"minLength": 2,
		"invalid": {
			"invalid_recording": {
				"type": "system",
				"data": 514
			},
			"invalid_retry_recording": {
				"type": "system",
				"data": 515
			},
			"retry": 1,
			"destination": {
				"type": "ivr",
				"data": 1111
			}
		},
		"timeout": {
			"timeout_recording": {
				"type": "system",
				"data": 516
			},
			"timeout_retry_recording": {
				"type": "system",
				"data": 515
			},
			"retry": 2,
			"destination": {
				"type": "department",
				"data": 1254
			}
		},
		"destination": {
			"1": {
				"type": "IVR",
				"id": "121"
			},
			"25": {
				"type": "api_dialplan",
				"id": "sample_api_dialplan_id456cde"
			}
		}
	}
}]