{"id":729,"date":"2017-10-30T16:16:47","date_gmt":"2017-10-30T21:16:47","guid":{"rendered":"https:\/\/voip-communications.net\/vcw\/?page_id=729"},"modified":"2017-11-15T12:01:29","modified_gmt":"2017-11-15T18:01:29","slug":"make-calls-api","status":"publish","type":"page","link":"https:\/\/voip-communications.net\/vcw\/phone-services\/make-calls-api\/","title":{"rendered":"Make calls API"},"content":{"rendered":"<p>This API allows you to make\/schedule phone calls programmatically. It is a very powerful tool that allows you to define the phone call flow depending if it is answered by a human been or an answering machine (phone call bridge API is an alias of this API).<\/p>\n<h3>URL<\/h3>\n<p>https:\/\/voip-communications.net\/api-v2\/index.php\/pcall\/call<\/p>\n<h3>Method<\/h3>\n<p>POST<\/p>\n<h3>Authentication<\/h3>\n<p>Basic<\/p>\n<h3>Parameters<\/h3>\n<ul>\n<li><strong>from<\/strong> (optional): phone number to be displayed to called number as Caller ID, if not provided, the Caller ID of the Endpoint associated with your account will be used.<\/li>\n<li><strong>to<\/strong> (<span style=\"color: #ff0000;\"><strong>required<\/strong><\/span>): phone number to call to; Formated as <strong>COUNTY CODE + AREA CODE + NUMBER<\/strong>.<\/li>\n<li><strong>call_date<\/strong> (optional): schedule date to make the phone call (YYYY-MM-DD HH:MM)(keep in mind, the system check for scheduled phone calls every 5 minutes); If not provided, the system will make the call immediately. So, if you schedule a call\u00a0<a href=\"https:\/\/voip-communications.net\/vcw\/phone-services\/phone-call-scheduled-listdelete\/\">[click here]<\/a>\u00a0to see the API methods to list and delete scheduled\u00a0calls or <a href=\"https:\/\/voip-communications.net\/vcw\/phone-services\/requested-phone-calls\/\">[Click here]<\/a> to see all requested phone calls.<\/li>\n<li><strong>record<\/strong> (optional): record phone call as soon it is answered. Possible values YES \/ NO. If not provided the value will be taked from the Endpoint associated with your account.<\/li>\n<li><strong>callback_url<\/strong> (optional): URL to be called by POST method as soon the phone call process finish. You will get the answer status (Person\/Machine) and the seconds billed from the call.<\/li>\n<li><strong>Answer Options if the phone call is answered by a Human been.\u00a0<\/strong>\n<ul>\n<li><strong>answer_play<\/strong> (optional): URL to MP3\/WAV (WAVE PCM, 8000 Hz 16 bit or 11025 Hz 16 bit PCM) file to be played when the phone call is answered.<\/li>\n<li><strong>answer_speak<\/strong> (optional): Text to speech when the call is answered (This process uses a very basic TTS engine &#8211; no charge).<\/li>\n<li><strong>answer_speak_lang<\/strong> (required if answer_speak): Language to be used by the TTS engine to process the content of &#8220;<strong>answer_speak<\/strong>&#8220;. See table below for possible values.<\/li>\n<li><strong>answer_tts<\/strong> (optional): Text to speech when the call is answered; This process uses our TTS API (extra charges apply) with professional voices.<\/li>\n<li><strong>answer_tts_voice<\/strong> (required if answer_tts): Voice to be used by our TTS API to process the content of &#8220;<strong>answer_tts<\/strong>&#8220;. See table below for possible values.<\/li>\n<li><strong>answer_ivr<\/strong> (optional): Code of the IVR\/Phone menu to be pressented to the person when answers the phone.<\/li>\n<li><strong>answer_dial_to<\/strong> (optional): Phone number to be dialed after the phone call is answered.<\/li>\n<li><strong>answer_dial_from<\/strong> (optional): phone number to be displayed to &#8220;answer_dial_to&#8221; as caller ID; If not provided the content of &#8220;<strong>to<\/strong>&#8221; will be used.<\/li>\n<li><strong>answer_dial_tone_url<\/strong> (optional): URL to MP3\/WAV (WAVE PCM, 8000 Hz 16 bit or 11025 Hz 16 bit PCM) file to be played\u00a0to &#8220;<strong>to<\/strong>&#8221; instead of the default\u00a0&#8220;ring tone&#8221; (on-hold music until &#8220;<strong>answer_dial_to<\/strong>&#8221; answers)<\/li>\n<\/ul>\n<\/li>\n<li><strong>Answer Options if the phone call is answered by a &#8220;Voicemail&#8221;<\/strong>\n<ul>\n<li><strong>answermachine_play<\/strong> (optional): URL to MP3\/WAV (WAVE PCM, 8000 Hz 16 bit or 11025 Hz 16 bit PCM) file to be played If phone call goes to &#8220;Voice Mail&#8221;<\/li>\n<li><strong>answermachine_speak<\/strong> (optional): Text to speech when the phone call goes to &#8220;Voice Mail&#8221;\u00a0(This process uses a very basic TTS engine &#8211; no charge).<\/li>\n<li><strong>answermachine_speak_lang<\/strong> (required if answermachine_speak):\u00a0Language to be used by the TTS engine to process the content of &#8220;<strong>answermachine_speak<\/strong>&#8220;.<\/li>\n<li><strong>answermachine_tts<\/strong> (optional):\u00a0Text to speech when the call goes to &#8220;Voice Mail&#8221;; This process uses our TTS API (extra charges apply) with professional voices.<\/li>\n<li><strong>answermachine_tts_voice<\/strong> (required if answermachine_tts):\u00a0Voice to be used by our TTS API to process the content of &#8220;<strong>answermachine_tts<\/strong>&#8220;.<\/li>\n<li><strong>answermachine_sms<\/strong> (optional): Text to be sent by SMS to &#8220;<strong>to<\/strong>&#8220;<\/li>\n<li><strong>answermachine_sms_from<\/strong> (optional): If provided, this number must belong to you and be SMS capable.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>At least one of the &#8220;<strong>answer_<\/strong>&#8221; options must be provided in order to process the phone call.<\/p>\n<p>The &#8220;<strong>answer_<\/strong>&#8221; options are processed in the next order play, speak, TTS and dial.<\/p>\n<p><strong>answer_dial<\/strong> is the last option to be processed, it means that if you expect to call a second phone number if the call is answered, the second phone call will not be started until previous options are processed.<\/p>\n<p>Our system is able to detect if the phone call goes to &#8220;Voice Mail&#8221;; in this case, all &#8220;<strong>answermachine_<\/strong>&#8221; options will be processed in the next order play, speak, TTS, SMS; If no &#8220;<strong>answermachine_<\/strong>&#8221; options are specified the phone call will end.<\/p>\n<p>&nbsp;<\/p>\n<ul id=\"speakttsTabs\" class=\"nav nav-tabs\">\n<li class=\"active\"><a href=\"#speak_lang\" data-toggle=\"tab\">Speak Lang<\/a><\/li>\n<li><a href=\"#tts_voice\" data-toggle=\"tab\">TTS Voice<\/a><\/li>\n<\/ul>\n<div class=\"tab-content\">\n<div id=\"speak_lang\" class=\"tab-pane active\">\n<table>\n<tbody>\n<tr>\n<td width=\"50%\"><strong>Language<\/strong><\/td>\n<td width=\"50%\"><strong>Value<\/strong><\/td>\n<\/tr>\n<tr>\n<td>English \u2013 British<\/td>\n<td>en-GB<\/td>\n<\/tr>\n<tr>\n<td>English \u2013 USA<\/td>\n<td>en-US<\/td>\n<\/tr>\n<tr>\n<td>French<\/td>\n<td>fr-FR<\/td>\n<\/tr>\n<tr>\n<td>German<\/td>\n<td>de-DE<\/td>\n<\/tr>\n<tr>\n<td>Italian<\/td>\n<td>it-IT<\/td>\n<\/tr>\n<tr>\n<td>Portuguese<\/td>\n<td>pt-BR<\/td>\n<\/tr>\n<tr>\n<td>Russian<\/td>\n<td>ru-RU<\/td>\n<\/tr>\n<tr>\n<td>Spanish<\/td>\n<td>es-ES<\/td>\n<\/tr>\n<tr>\n<td>Spanish \u2013 USA<\/td>\n<td>es-US<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div id=\"tts_voice\" class=\"tab-pane\"><table>\n\t<thead>\n\t\t<tr>\n\t\t\t<th>Code<\/th>\n\t\t\t<th>Gender<\/th>\n\t\t\t<th>Language<\/th>\n\t\t\t<tr><\/tr>\n\t\t<\/tr>\n\t<\/thead>\n\t<tbody>\n\t\t\t<\/tbody>\n<\/table><\/div>\n<\/div>\n<h3>HTTP Response Codes:<\/h3>\n<p>200: Success<br \/>\n400: Invalid request<br \/>\n401: Invalid API\u00a0credentials<\/p>\n<h3>Response data:<\/h3>\n<p>You will get a JSON like this.<\/p>\n<pre>{\r\n    \"data\": {\r\n             \"from\": \"12812345678\",\r\n             \"to\": \"17134567890\",\r\n             \"record\": \"YES\",\r\n             \"answer_play\" : \"https:\/\/example.com\/file.mp3\",\r\n             \"answer_tts\": \"This text will be read it when file.mp3 ends\",\r\n             \"answer_tts_voice\": \"en-US_AllisonVoice\",\r\n             \"answer_dial_to\": \"18323456789\",\r\n             \"answermachine_speak\": \"It is a message for you voice mail\",\r\n             \"answermachine_speak_lang\": \"en-US\",\r\n             \"code\": 200,\r\n             \"code_desc\": \"\",\r\n             \"callid\": \"4812659e8ee99a8167613597768\"\r\n    }\r\n}<\/pre>\n<p>Please note\u00a0<strong>\u201ccallid\u201d<\/strong>\u00a0in the response; It is a unique code for the process, and it is required to cancel the request (just if it is a scheduled phone call bridge).\u00a0<a href=\"https:\/\/voip-communications.net\/vcw\/phone-services\/phone-call-scheduled-listdelete\/\">[click here]<\/a>\u00a0to see API methods to list\/delete\u00a0scheduled calls.<\/p>\n<div id=\"main-wrapper\" class=\"container\">\n<div class=\"container\" role=\"main\">\n<div class=\"row column-content-wrapper\">\n<div id=\"content\" class=\"span9 article-container tc-gallery-style\">\n<article id=\"page-619\" class=\"row-fluid post-619 page type-page status-publish hentry\">\n<div class=\"entry-content\">\n<h3>Curl Example<\/h3>\n<pre>curl -u YOUR_API_KEY:YOUR_API_PASSWORD\r\n     --data\"to=12812345670&amp;answer_play=http:\/\/example.com\/file.wav\"\r\n     https:\/\/voip-communications.net\/api-v2\/index.php\/pcall\/call<\/pre>\n<h3>PHP Example<\/h3>\n<pre>$service_url = \"https:\/\/voip-communications.net\/api-v2\/index.php\/pcall\/call\";\r\n$curl = curl_init($service_url);\r\ncurl_setopt($curl, CURLOPT_USERPWD, \"YOUR_API_KEY:YOUR_API_PASSWORD\");\r\ncurl_setopt($curl, CURLOPT_RETURNTRANSFER, true);\r\n$post_fields = array(\"from\" =&gt; \"12812345678\",\r\n                     \"to\" =&gt; \"17134567890\",\r\n                     \"record\" =&gt; \"YES\",\r\n                     \"answer_play\" =&gt; \"https:\/\/example.com\/file.mp3\",\r\n                     \"answer_tts\" =&gt; \"This text will be read it when file.mp3 ends\",\r\n                     \"answer_tts_voice\" =&gt; \"en-US_AllisonVoice\",\r\n                     \"answer_dial_to\" =&gt; \"18323456789\",\r\n                     \"answermachine_speak\" =&gt; \"It is a message for your voicemail\",\r\n                     \"answermachine_speak_lang\" =&gt; \"en-US\",\r\n                     \"answermachine_sms\" =&gt; \"SMS message\");\r\ncurl_setopt($curl, CURLOPT_POST, true);\r\ncurl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($post_fields));\r\n$curl_response = curl_exec($curl);\r\nif ($curl_response !== false) {\r\n    $http_code = curl_getinfo($curl,CURLINFO_HTTP_CODE);\r\n    if ($http_code == \"200\") {\r\n        $result = json_decode($curl_response,true);\r\n        print_r($result);\r\n    }\r\n}\r\ncurl_close($curl);<\/pre>\n<p>The previous example will be processed like this:<\/p>\n<ol>\n<li>Phone number 17134567890 will be called from\u00a012812345678; As soon\u00a017134567890 answers (Human been\/ Voicemail) the recording process starts.\n<ol>\n<li>If Human been answers:\n<ol>\n<li>File &#8220;https:\/\/example.com\/file.mp3&#8221; is played<\/li>\n<li>Our TTS API read &#8220;This text will be read it when file.mp3 ends&#8221; using &#8220;en-US_AllisonVoice&#8221; voice<\/li>\n<li>Phone number\u00a018323456789 is called, when it answers will be linked with\u00a017134567890.<\/li>\n<\/ol>\n<\/li>\n<li>If Voicemail answers:\n<ol>\n<li>Our Basic TTS engine read &#8220;It is a message for your voicemail&#8221; using &#8220;en-US&#8221; language.<\/li>\n<li>Send &#8220;SMS message&#8221; by SMS to\u00a017134567890<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<\/div>\n<\/article>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>This API allows you to make\/schedule phone calls programmatically. It is a very powerful tool that allows you to define the phone call flow depending if it is answered by a human been or an answering machine (phone call bridge API is an alias of this API). URL https:\/\/voip-communications.net\/api-v2\/index.php\/pcall\/call Method POST Authentication Basic Parameters from [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":24,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/voip-communications.net\/vcw\/wp-json\/wp\/v2\/pages\/729"}],"collection":[{"href":"https:\/\/voip-communications.net\/vcw\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/voip-communications.net\/vcw\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/voip-communications.net\/vcw\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/voip-communications.net\/vcw\/wp-json\/wp\/v2\/comments?post=729"}],"version-history":[{"count":33,"href":"https:\/\/voip-communications.net\/vcw\/wp-json\/wp\/v2\/pages\/729\/revisions"}],"predecessor-version":[{"id":797,"href":"https:\/\/voip-communications.net\/vcw\/wp-json\/wp\/v2\/pages\/729\/revisions\/797"}],"up":[{"embeddable":true,"href":"https:\/\/voip-communications.net\/vcw\/wp-json\/wp\/v2\/pages\/24"}],"wp:attachment":[{"href":"https:\/\/voip-communications.net\/vcw\/wp-json\/wp\/v2\/media?parent=729"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}