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.

function ttsCall(<Your Text>, cb){
 msg = msg.substr(0,360)
 var options = {
 "method": "GET",
 "hostname": <TTS API HOST>,
 "port": <TTS API PORT>,
 "path": "/tts?
 };
 console.log("options---",options)
 var TTSreq = http.request(options, function (TTSres) {
 var chunks = [];
 TTSres.on("data", function (chunk) {
 chunks.push(chunk);
 });
 TTSres.on('error', function (e) {
 console.log("EROOR in TTSres : ", e); 
 TTSreq.abort();
 cb(null);
 });
 TTSres.on("end", function () {
 var body = Buffer.concat(chunks).toString();
 console.log("body---",body)
 cb(body) 
 });
 });
 TTSreq.on('error', function (e) {
 console.log("EROOR in TTSreq : ", e);
 TTSreq.abort();
 cb(null);
 });
 
 TTSreq.setTimeout(60000, function () {
 TTSreq.abort();
 cb(null);
 })
 TTSreq.end(); 
};

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 Greeting call

4

 

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

05. Integrate Exotel API

function executeCall(phone_no, filePath, cb) {

 exotel = require('exotel-client');
 exotel.init('<Exotel SID>', '<Exotel Token>');

 exotel.call_flow('<Your Number>', '<Exo Phone Numbers>', '<App ID>', function(err,data){
 console.log("call done",data)
 data = JSON.parse(data);
 var sid = '',status = '';
 sid = (data.RestException) ? 'NA' : data.Call.Sid;
 status = (data.RestException) ? 'Failed' : 'Success';
 var value = [sid,filePath,phone_no]
 sqlquery.insert('call_info',value,function(result){
 cb("pass")
 })
 });
};

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