NotifyPhoneAdvanced
This method calls any phone number and read aloud the contents of TextToSay
. Use NotifyMultiplePhoneAdvanced
to call multiple phone numbers.
Syntax
NotifyPhoneAdvanced(Request)
Request Parameters
Parameter Name | Description | Data Type | Required | Sample Value |
---|---|---|---|---|
PhoneNumberToDial |
The phone number to call. It can be in any format, as long as there are 10 digits. To dial an extension, add |
String
|
True | 7575559999 |
TransferNumber |
The phone number that the call will be transferred to if the call recipient presses |
String
|
False | 7575558888 |
VoiceID |
The text-to-speech voice ID. |
Integer
|
True | 2 |
CallerIDNumber |
The number to display on the receiving party's Caller ID. |
String
|
False | 7575550000 |
CallerIDName |
The name to display on the receiving party's Caller ID. (Most carriers ignore this and use their own directory assistance to display name information.) |
String
|
False | Esendex Services |
TextToSay |
The text-to-speech text or combination of text-to-speech and script to be read to the receiving party. |
String
|
True | Hello, this is a sample call from Phone Notify. |
LicenseKey |
Your license key. |
String
|
True | 00000000-0000-0000-0000-000000000000 |
TryCount |
The number of times to attempt dialing if the initial call is unanswered or busy. The maximum is |
Integer
|
True | 2 |
NextTryInSeconds |
The number of seconds to wait until the next retry is performed if the original call is unanswered or busy. We recommend waiting at least 60 seconds. |
Integer
|
True | 180 |
UTCScheduledDateTime |
The date and time at which to send the call, specified as Coordinated Universal Time (UTC). |
DateTime
|
True | 2020-11-17T08:25:08.336Z |
TTSrate |
The speed that text-to-speech (TTS) will use when speaking the text. The value ranges from |
Byte
|
True | 10 |
TTSvolume |
The volume that text-to-speech (TTS) will use when speaking the text. The value ranges from |
Byte
|
True | 100 |
MaxCallLength |
The maximum time duration of the call, in seconds. We recommend you do not change this unless you absolutely need to. |
Integer
|
True | 80 |
StatusChangePostUrl |
The URL to post call status changes to. The URL must be in lowercase. The system posts |
String
|
False | https://example.com/callprogress.aspx |
ReferenceID |
An optional ID to help you identify the call. |
String
|
False | notify1 |
Response
Returns: NotifyReturn
object
Code Samples
You can use any programming language you want with our API, as long as it can make a REST or SOAP call. Here are examples for some of the most common platforms.
/* https://ws.esendex.us/notifyws/phonenotify.asmx?wsdl was added as a Service Reference and given the name WSDL */
using WSDL;
var client = new PhoneNotifySoapClient(PhoneNotifySoapClient.EndpointConfiguration.PhoneNotifySoap);
var request = new AdvancedNotifyRequest
{
PhoneNumberToDial = YOUR_TO_NUMBER,
TextToSay = "Hello, this is a test call.",
UTCScheduledDateTime = DateTime.UtcNow,
LicenseKey = YOUR_LICENSE_KEY
};
var response = await client.NotifyPhoneAdvancedAsync(request);
Console.WriteLine(
"QueueID: " + response.QueueID + Environment.NewLine +
"Response Code: " + response.ResponseCode + Environment.NewLine +
"Response Text: " + response.ResponseText
);
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.HttpURLConnection;
import java.net.URL;
public final class NotifyPhoneAdvanced {
public static void main(String[] args) throws Exception {
String responseContent = "";
String response = "";
URL url = new URL("https://ws.esendex.us/NotifyWS/PhoneNotify.asmx");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
StringBuilder sb = new StringBuilder("<?xml version='1.0' encoding='utf-8'?>");
sb.append(
"<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">");
sb.append("<soap:Body>");
sb.append("<NotifyPhoneAdvanced xmlns=\"https://ws.esendex.us/NotifyWS/\">");
sb.append("<anr>");
sb.append("<TransferNumber>17575449510</TransferNumber>");
sb.append("<PhoneNumberToDial>17575449510</PhoneNumberToDial>");
sb.append("<VoiceID>1</VoiceID>");
sb.append("<CallerIDNumber>18009843710</CallerIDNumber>");
sb.append("<CallerIDName>Test</CallerIDName>");
sb.append("<TextToSay>Hello this is a test.</TextToSay>");
sb.append("<LicenseKey>00000000-0000-0000-0000-000000000000</LicenseKey>");
sb.append("<NextTryInSeconds>5</NextTryInSeconds>");
sb.append("<TryCount>5</TryCount>");
sb.append("<UTCScheduledDateTime>2013-01-15T20:53:00.608Z</UTCScheduledDateTime>");
sb.append("<StatusChangePostUrl>http://esendex.us/postback/notify/2015</StatusChangePostUrl>");
sb.append("</anr>");
sb.append("</NotifyPhoneAdvanced>");
sb.append("</soap:Body>");
sb.append("</soap:Envelope>");
connection.setRequestProperty("Content-Length", String.valueOf(sb.toString().length()));
connection.setRequestProperty("Content-Type", "text/xml");
connection.setRequestProperty("Connection", "Close");
connection.setRequestProperty("SoapAction", "https://ws.esendex.us/NotifyWS/NotifyPhoneAdvanced");
connection.setDoInput(true);
connection.setDoOutput(true);
PrintWriter pw = new PrintWriter(connection.getOutputStream());
pw.write(sb.toString());
pw.flush();
connection.connect();
System.out.println(sb.toString());
BufferedReader br;
if (connection.getResponseCode() == 200) {
br = new BufferedReader(new InputStreamReader(connection.getInputStream()));
} else {
br = new BufferedReader(new InputStreamReader(connection.getErrorStream()));
}
// BufferedReader br = new BufferedReader(new
// InputStreamReader(connection.getInputStream()));
while ((responseContent = br.readLine()) != null) {
response += responseContent;
}
System.out.println(response);
}
}
define("ALERTD_LICENSE_KEY", 'secretKeyHere');
define("ALERTD_POST_STATUS_URL", 'https://www.example.com/callback-URL/');
define("ALERTD_CALLER_ID_NUMBER", '6175551212'); // caller id "from" number
define("ALERTD_CALLER_ID_NAME", 'Example.com');
try {
$queueID = phone_notify_queueCall('6175551234', 'Test');
print "OK QueueID=$queueID";
}
catch (Exception $e) {
print "ERROR " . $e->getMessage();
}
/** Queue a phone call to a given number. Returns the Esendex queue ID, or throws an exception if the call is not queued successfully. */
function phone_notify_queueCall($phoneNumber, $message) {
$message = "~\SetVar(maxcallseconds|120)~
~\StatusChangePostURL(" . ALERTD_POST_STATUS_URL . ")~ "
. $message .
" Press any key to confirm you have received this message.
~\GetDigits(UserConfirmation|4)~
Thank you. Goodbye.
~\EndCall()~
";
try {
$client = new SoapClient(' https://ws.esendex.us/NotifyWS/PhoneNotify.asmx?wsdl');
$result = $client->NotifyPhoneAdvanced( new CallRequestData($phoneNumber, $message) );
$ResponseCode = $result->NotifyPhoneAdvancedResult->ResponseCode;
$ResponseText = $result->NotifyPhoneAdvancedResult->ResponseText;
$queueID = $result->NotifyPhoneAdvancedResult->QueueID;
if ($ResponseCode == '0' || $ResponseText == 'Queued') {
var_dump( $client->GetQueueIDStatusWithAdvancedInfo( new GetQueueIDStatusData($queueID) ) );
return $queueID;
}
throw new Exception("Service returned queueing error: ResponseCode=$ResponseCode; ResponseText=$ResponseText");
} catch (Exception $e) {
// This will catch SOAP exceptions as well.
throw new Exception("Unable to queue call: " . $e->getMessage());
}
}
/** Parameters for Esendex CallRequestData call */
class CallRequestData {
public $anr;
function CallRequestData($number,$text) {
$this->anr = array();
$this->anr['PhoneNumberToDial'] = $number;
$this->anr['TextToSay'] = $text;
$this->anr['LicenseKey'] = ALERTD_LICENSE_KEY;
$this->anr['CallerIDNumber'] = ALERTD_CALLER_ID_NUMBER;
$this->anr['CallerIDName'] = ALERTD_CALLER_ID_NAME;
$this->anr['StatusChangePostUrl'] = ALERTD_POST_STATUS_URL;
$this->anr['TransferNumber'] = '';
$this->anr['NextTryInSeconds'] = 180;
$this->anr['MaxCallLength'] = 120;
$this->anr['TryCount'] = 5;
$this->anr['TTSvolume'] = 100;
$this->anr['TTSrate'] = 25;
$this->anr['UTCScheduledDateTime'] = '1970-01-01T00:00:00Z';
$this->anr['VoiceID'] = 1;
}
}
/** Parameters for Esendex GetQueueIDStatus call */
class GetQueueIDStatusData {
public $QueueID;
public $LicenseKey;
function GetQueueIDStatusData($id) {
$this->QueueID = $id;
$this->LicenseKey = ALERTD_LICENSE_KEY;
}
}
from datetime import datetime, timedelta
import zeep
client = zeep.Client(wsdl="https://ws.esendex.us/notifyws/phonenotify.asmx?wsdl")
dt = datetime.utcnow() + timedelta(minutes=1)
scheduled_utc_date_time = f"{dt.isoformat()}Z"
request = {
"PhoneNumberToDial": "17575559999",
"VoiceID": 1,
"CallerIDNumber": "7575550000",
"CallerIDName": "Esendex Services",
"TextToSay": "Hello, this call was sent with Python.",
"LicenseKey": "00000000-0000-0000-0000-000000000000",
"TryCount": 2,
"NextTryInSeconds": 180,
"UTCScheduledDateTime": dt,
"TTSrate": 10,
"TTSvolume": 100,
"MaxCallLength": 0,
}
result = client.service.NotifyPhoneAdvanced(request)
print(result)
POST /NotifyWS/PhoneNotify.asmx HTTP/1.1
Host: ws.esendex.us
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "https://ws.esendex.us/NotifyWS/NotifyPhoneAdvanced"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<NotifyPhoneAdvanced xmlns="https://ws.esendex.us/NotifyWS/">
<anr>
<PhoneNumberToDial>string</PhoneNumberToDial>
<TransferNumber>string</TransferNumber>
<VoiceID>int</VoiceID>
<CallerIDNumber>string</CallerIDNumber>
<CallerIDName>string</CallerIDName>
<TextToSay>string</TextToSay>
<LicenseKey>string</LicenseKey>
<TryCount>int</TryCount>
<NextTryInSeconds>int</NextTryInSeconds>
<UTCScheduledDateTime>dateTime</UTCScheduledDateTime>
<TTSrate>unsignedByte</TTSrate>
<TTSvolume>unsignedByte</TTSvolume>
<MaxCallLength>int</MaxCallLength>
<StatusChangePostUrl>string</StatusChangePostUrl>
<ReferenceID>string</ReferenceID>
</anr>
</NotifyPhoneAdvanced>
</soap:Body>
</soap:Envelope>
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<NotifyPhoneAdvancedResponse xmlns="https://ws.esendex.us/NotifyWS/">
<NotifyPhoneAdvancedResult>
<ResponseCode>int</ResponseCode>
<ResponseText>string</ResponseText>
<CallAnswered>boolean</CallAnswered>
<QueueID>long</QueueID>
<TryCount>int</TryCount>
<Demo>boolean</Demo>
<DigitsPressed>string</DigitsPressed>
<MachineDetection>string</MachineDetection>
<Duration>int</Duration>
<StartTime>dateTime</StartTime>
<EndTime>dateTime</EndTime>
<MinuteRate>decimal</MinuteRate>
<Country>string</Country>
<CallComplete>boolean</CallComplete>
<TextToSay>string</TextToSay>
<VariableArray>
<Variable>
<VariableName>string</VariableName>
<VariableValue>string</VariableValue>
</Variable>
<Variable>
<VariableName>string</VariableName>
<VariableValue>string</VariableValue>
</Variable>
</VariableArray>
</NotifyPhoneAdvancedResult>
</NotifyPhoneAdvancedResponse>
</soap:Body>
</soap:Envelope>
POST /NotifyWS/PhoneNotify.asmx HTTP/1.1
Host: ws.esendex.us
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<NotifyPhoneAdvanced xmlns="https://ws.esendex.us/NotifyWS/">
<anr>
<PhoneNumberToDial>string</PhoneNumberToDial>
<TransferNumber>string</TransferNumber>
<VoiceID>int</VoiceID>
<CallerIDNumber>string</CallerIDNumber>
<CallerIDName>string</CallerIDName>
<TextToSay>string</TextToSay>
<LicenseKey>string</LicenseKey>
<TryCount>int</TryCount>
<NextTryInSeconds>int</NextTryInSeconds>
<UTCScheduledDateTime>dateTime</UTCScheduledDateTime>
<TTSrate>unsignedByte</TTSrate>
<TTSvolume>unsignedByte</TTSvolume>
<MaxCallLength>int</MaxCallLength>
<StatusChangePostUrl>string</StatusChangePostUrl>
<ReferenceID>string</ReferenceID>
</anr>
</NotifyPhoneAdvanced>
</soap12:Body>
</soap12:Envelope>
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<NotifyPhoneAdvancedResponse xmlns="https://ws.esendex.us/NotifyWS/">
<NotifyPhoneAdvancedResult>
<ResponseCode>int</ResponseCode>
<ResponseText>string</ResponseText>
<CallAnswered>boolean</CallAnswered>
<QueueID>long</QueueID>
<TryCount>int</TryCount>
<Demo>boolean</Demo>
<DigitsPressed>string</DigitsPressed>
<MachineDetection>string</MachineDetection>
<Duration>int</Duration>
<StartTime>dateTime</StartTime>
<EndTime>dateTime</EndTime>
<MinuteRate>decimal</MinuteRate>
<Country>string</Country>
<CallComplete>boolean</CallComplete>
<TextToSay>string</TextToSay>
<VariableArray>
<Variable>
<VariableName>string</VariableName>
<VariableValue>string</VariableValue>
</Variable>
<Variable>
<VariableName>string</VariableName>
<VariableValue>string</VariableValue>
</Variable>
</VariableArray>
</NotifyPhoneAdvancedResult>
</NotifyPhoneAdvancedResponse>
</soap12:Body>
</soap12:Envelope>