01. Register in Exotel

Link : https://my.exotel.in/auth/register

Register your account from above link, and fill all the details.

02. Get your authentication details

Login with your username and password,
and Go to https://my.exotel.in/indiantts/settings/site#api-settings page.

Site Settings Exotel

Get your Exotel SID and Exotel TOKEN, these details will require in Exotel REST API.

03. Text to Speech API

now using IndianTTS Text to Speech API and convert your text to audio format , reffer bellow code for TEXT to Speech API.

<?php
 header("Access-Control-Allow-Origin: *"); 
 header("Access-Control-Allow-Credentials: true ");
 header("Access-Control-Allow-Methods: OPTIONS, GET, POST");
 header("Access-Control-Allow-Headers: Content-Type, Depth, User-Agent, X-File-Size, 
 X-Requested-With, If-Modified-Since, X-File-Name, Cache-Control");

$host = '<TTS API HOST>';
$port = '<PORT>';
$text = <TEXT>;

$url = "http://".$host.":".$port."/tts?text=".$text;

$curl = curl_init();

curl_setopt_array($curl, array(
 CURLOPT_PORT => "<PORT>",
 CURLOPT_URL => $url,
 CURLOPT_RETURNTRANSFER => true,
 CURLOPT_ENCODING => "",
 CURLOPT_MAXREDIRS => 10,
 CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
 CURLOPT_CUSTOMREQUEST => "GET",
 CURLOPT_HTTPHEADER => array(
 ),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
 echo "cURL Error #:" . $err;
} else {
 echo $response;
}
?>

04. Create Exotel Call Flow

Now login with your username and password, https://my.exotel.in/ & click to “App Bazaar”.

Installed Apps Exotel

Click to create button, New popup is open and set your app name, e.g. Our App name is ‘Exotel flow’

  • Select greeting

Edit Voice Flow Flow Editor Exotel

Now click to greeting box.

  • Set Greeting
  • Audio Choice

Select ‘Type Text’ Option, then show text area which is ask you to enter text for greeting calls. Now we have two options here,

  1. Enter Text 
    • If you enter static text then every time you get same greeting calls.
  2. Enter your API url
    • If you enter your API url, then exotel every time send get request on your url and get response from your API
    • If your API response bake to dynamic text or audio URL then every time you getting dynamic

4

Greeting call

Please refer to : http://support.exotel.in/support/solutions/articles/48285-greeting-using-dynamic-text-or-audio-from-url

05. Integrate Exotel API

<?php
header("Access-Control-Allow-Origin: *"); 
 header("Access-Control-Allow-Credentials: true ");
 header("Access-Control-Allow-Methods: OPTIONS, GET, POST");
 header("Access-Control-Allow-Headers: Content-Type, Depth, User-Agent, X-File-Size, 
 X-Requested-With, If-Modified-Since, X-File-Name, Cache-Control");

$post_data = array(
 'From' => <Your Mobile Number>,
 'CallerId' => "<Exophones Number>",
 'Url' => "http://my.exotel.in/exoml/start/<App Id>",
 'CallType' => "trans"
);
 
$exotel_sid = "<Your Exotel SID>"; // Your Exotel SID - Get it here: http://my.exotel.in/Exotel/settings/site#exotel-settings
$exotel_token = "<Your Exotel TOKEN>"; // Your exotel token - Get it here: http://my.exotel.in/Exotel/settings/site#exotel-settings
$url = "https://".$exotel_sid.":".$exotel_token."@twilix.exotel.in/v1/Accounts/".$exotel_sid."/Calls/connect";
$ch = curl_init();
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FAILONERROR, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_data));
 
$http_result = curl_exec($ch);
$error = curl_error($ch);
$http_code = curl_getinfo($ch ,CURLINFO_HTTP_CODE);
curl_close($ch);
echo $http_result;
?>

Please check above code of API integration,
Now we need to save call execute details (CALL SID) and TTS audio URL into our database for dynamic greeting call, In my example I am using mysql DB
Now create new GET method for Exotel, if any call executed & user are receive that call then exotel call to our API, refer point number #3 for API URL, that API URL response to exotel with audio URL

06. Log Entry Provide by Exotel

exotel