KooKoo tunes is nothing but the name given to markup language which powers the KooKoo platform. Using different KooKoo tunes you can make your application sing :). The heart of the KooKoo platform is a simple request response model. Your web application requests the platform to perform a specific action like play some text, collect some user input or record user voice etc. KooKoo performs the action and responds with a result if a result exists. The following are the KooKoo tunes available at your disposal:
<?xml version="1.0" encoding="UTF-8"?> <Response> <playtext>Hello World</playtext> </Response>
<?xml version="1.0" encoding="UTF-8"?> <Response sid="12345"> <playtext>Hello World</playtext> </Response>
<?xml version="1.0" encoding="UTF-8"?> <response> <playtext type="ggl" quality="best">Hello World</playtext> </response>
Format | Code | Text | Lang | Play As |
---|---|---|---|---|
Date | 201 | 20110721 | EN | Thursday July 21st 2011 |
Date | 202 | 20110721 | EN | July 21st 2011 |
Date | 204 | 20110721 | EN | July 21st |
Currency | 402 | 53 | EN | Fifty three rupees and zero zero paise |
Currency | 401 | 53 | EN | it ignores numbers after decimal point |
Digits | 501 | 1234 | EN | one two three four |
Number | 1 | 1234 | EN | one thousand two hundred and thirty four |
<?xml version="1.0" encoding="UTF-8"?>It will be played as "one two three A B C";
<response> <say-as format="501" lang="EN">123ABC</say-as>
</response>
<?xml version="1.0" encoding="UTF-8"?>It will be played as "December 27 2012";
<response> <say-as format="222" lang="EN">20121227ABC</say-as>
</response>
<?xml version="1.0" encoding="UTF-8"?>
<response> <playaudio>http://www.ozonetel.com/test.wav</playaudio>
</response>
<?xml version="1.0" encoding="UTF-8"?>
<response sid="12345">
<collectdtmf l="4" t="#" o="5000">
<playtext>Please enter your pin number
</playtext>
</collectdtmf>
</response>
<?xml version="1.0" encoding="UTF-8"?>
<response sid="12345">
<record format="mp3" silence="3" maxduration="30" >myfilename</record>
</response>
<?xml version="1.0" encoding="UTF-8"?>
<response>
<conference caller_onhold_music="default" record="true">2345</conference>
</response>
<?xml version="1.0" encoding="UTF-8"?>
<response>
<gotourl>http://host../nextapp.app</gotourl>
</response>
<?xml version="1.0" encoding="UTF-8"?>
<response>
<hangup></hangup>
</response>
<dial record="true" limittime="1000" timeout="30" moh="default" >09912343234</dial>
Attribute | Values |
---|---|
type |
zena , ggl
speech engine to use, default engine is:zena zena : Ozonetel speech engine ggl : Google speech engine ggl stream : Google Stream speech engine (Contact Support) Note : Google stream recognition we are offering only from Hyderabad and Bangalore |
grammar |
digits,yesno
It only works with zena speech engine
|
length |
integer value
It works with grammar=digits only. It is to set maximum length of digits to recognise
ex: for 4 digit pin number length has to set to 4 |
timeout | Maximum wait time in seconds for user to record the voice default timeout value is 10 seconds |
lang |
en-IN , hi-IN
Set base language, supports both speech engines default language is : en-IN en-IN : Indian English hi-IN : Indian Hindi |
timeout | Maximum wait time in seconds for user to record the voice default timeout value is 10 seconds |
silence | Maximum wait time for voice input, in case of no input within the duration specified time. It assumes no voice provided default silence value is 3 seconds |
In order to use the KooKoo php library, click this to download KooKoo PHP library and include it in your source code.
------- Play Text Example -------- <?php require 'response.php';//include response.php into your code $r = new response(); $r->addPlayText("I Love Koo Koo"); // Play any text to play $r->addHangup(); $r->send(); ?> ------- SayAs Tag Example -------- <?php /*** * Use Say-As Tag for play Dynamic content like playing number or digits * */ require 'response.php';//include response.php into your code $r = new response(); $r->addSayAs("1234",501,'EN'); // Play any text to play $r->addHangup(); $r->send(); ?> ---------- PlayAudio Tag Example Code ---------- <?php /*** * Use PlayAudio Tag to play pre-recorded audio file */ require 'response.php';//include response.php into your code $r = new response(); $r->addPlayAudio("http://yourhost.com/welcome.wav"); // Play any text to play $r->addHangup(); $r->send(); ?>---------------------------Collect DTMF Example------------------------------------------------- <?php /* * * * Use Collect DTMF to collect DTMF input from user. */ require 'response.php'; //include response.php into your code $r = new response(); if (isset($_REQUEST['event']) && $_REQUEST['event'] == 'NewCall') { $cd = new CollectDtmf(); //initiate new collect dtmf object $cd->addPlayText("Press 1, for sales"); $cd->addPlayText("Press 1, for to know about our company"); $r->addCollectDtmf($cd); } elseif (isset($_REQUEST['event']) && $_REQUEST['event'] == 'GotDTMF') { if (isset($_REQUEST['data']) && !empty($_REQUEST['data'])) { $r->addPlayText("you have pressed D T M F" . $_REQUEST['data']); } else { $r->addPlayText("you have not given any input please re enter"); $cd = new CollectDtmf(); //initiate new collect dtmf object $cd->addPlayText("Press 1, for sales"); $cd->addPlayText("Press 1, for to know about our company"); $r->addCollectDtmf($cd); } }else{ $r->addHangup(); } $r->send(); ?>---------------------------Record Tag Example------------------------------------------------- <?php /* * * * Use Record Tag, To record message. recorded message will be pushed application as URL */ require 'response.php'; //include response.php into your code $r = new response(); if (isset($_REQUEST['event']) && $_REQUEST['event'] == 'NewCall') { $r->addPlayText("Please record your message"); $r->addRecord("recordFileName"); } elseif (isset($_REQUEST['event']) && $_REQUEST['event'] == 'Record') { $r->addPlayText("your recorded message is "); $r->addPlayAudio($_REQUEST['data']); }else{ $r->addHangup(); } $r->send(); ?>---------------------------Conference Tag Example------------------------------------------------- <?php /* * * * Conference Tag Example * */ require 'response.php'; //include response.php into your code $r = new response(); if (isset($_REQUEST['event']) && $_REQUEST['event'] == 'NewCall') { $r->addPlayText("You are joining into conference"); $r->addConference("1234"); //1234->is conference nummbr } elseif (isset($_REQUEST['event']) && $_REQUEST['event'] == 'Conference') { $r->addPlayText("your recorded message is "); $r->addPlayAudio($_REQUEST['data']); } else { $r->addHangup(); } $r->send(); ?>---------------------------Goto Tag Example------------------------------------------------- <?php /* * * * GoTo Tag Example */ require 'response.php'; //include response.php into your code $r = new response(); $r->addGoto("http://your.public.host/nextapp.php"); $r->addHangup(); $r->send(); ?>---------------------------Hangup Tag Example------------------------------------------------- <?php /* * * * Hangup Tag Example */ require 'response.php'; //include response.php into your code $r = new response(); $r->addHangup(); //simply add hangup tag to disconnect $r->send(); ?>---------------------------Dial Tag Example------------------------------------------------- <?php /* * * * Dial Tag Example * */ require 'response.php'; //include response.php into your code $r = new response(); if (isset($_REQUEST['event']) && $_REQUEST['event'] == 'NewCall') { $r->addPlayText("Please wail while we connecting"); $r->addDial("09xxxx"); //phone number to dial } elseif (isset($_REQUEST['event']) && $_REQUEST['event'] == 'Dial') { if ($_REQUEST['status'] == 'answered') { $r->addPlayText("dialled number is answered"); } else { $r->addPlayText("dialled number is not answered"); } $r->addHangup(); } else { $r->addHangup(); } $r->send(); ?>>
In order to use the KooKoo java library, just download KooKoo Java library and include it in your source code.
--- playText Example code ----- import com.ozonetel.kookoo.Response; //add and import kookoo response.jar or source code into your application import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @WebServlet(name = "testIvr", urlPatterns = {"/testIvr"}) public class testIvr extends HttpServlet { /** * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/xml;charset=UTF-8"); Response r = new Response(); //create kookoo Response Object r.addPlayText("I Love Koo Koo"); // add play text object r.addHangup(); String kookooResponseOutput = r.getXML(); try (PrintWriter out = response.getWriter()) { out.println(kookooResponseOutput); } } } ----------------------------------------------------------------------------------------------------------PlayAudio Example------------------------------------- import com.ozonetel.kookoo.Response; //add and import kookoo response.jar or source code into your application import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @WebServlet(name = "testIvr", urlPatterns = {"/testIvr"}) public class testIvr extends HttpServlet { /** * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/xml;charset=UTF-8"); Response r = new Response(); //create kookoo Response Object r.addPlayAudio("http://your...host/audios/welcome.wav"); // play pre-recorded files r.addHangup(); String kookooResponseOutput = r.getXML(); try (PrintWriter out = response.getWriter()) { out.println(kookooResponseOutput); } } }-------- CollectDTMF Tag Example ---- import com.ozonetel.kookoo.Response; //add and import kookoo response.jar or source code into your application import com.ozonetel.kookoo.CollectDtmf;//import collectdtmf class import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @WebServlet(name = "testIvr", urlPatterns = {"/testIvr"}) public class testIvr extends HttpServlet { /** * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/xml;charset=UTF-8"); String event = request.getParameter("event"); Response r = new Response(); //create kookoo Response Object if ((null != event) && event.equalsIgnoreCase("NewCall")) { CollectDtmf cd = new CollectDtmf(1, "#", 5); cd.addPlayText("Press 1 for sales"); cd.addPlayText("Press 2, for know about our company"); r.addCollectDtmf(cd); } else if ((null != event) && event.equalsIgnoreCase("GotDTMF")) { r.addPlayText("you have entered number is " + request.getParameter("data")); r.addHangup(); } else { r.addPlayText("call is disconnecting " ); r.addHangup(); } String kookooResponseOutput = r.getXML(); try (PrintWriter out = response.getWriter()) { out.println(kookooResponseOutput); } } }-------- Record Tag Example ---- import com.ozonetel.kookoo.Response; //add and import kookoo response.jar or source code into your application import com.ozonetel.kookoo.Record; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @WebServlet(name = "testIvr", urlPatterns = {"/testIvr"}) public class testIvr extends HttpServlet { /** * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/xml;charset=UTF-8"); String event = request.getParameter("event"); Response r = new Response(); //create kookoo Response Object if ((null != event) && event.equalsIgnoreCase("NewCall")) { r.addPlayText("Please say your message after beep"); Record rec = new Record(); rec.setFileName("recordFileName"); rec.setMaxDuration(15); r.addRecord(rec); } else if ((null != event) && event.equalsIgnoreCase("Record")) { r.addPlayText("message recored by you is :"); r.addPlayAudio(request.getParameter("data")); r.addHangup(); } else { r.addPlayText("call is disconnecting "); r.addHangup(); } String kookooResponseOutput = r.getXML(); try (PrintWriter out = response.getWriter()) { out.println(kookooResponseOutput); } } } ---Dial Tag Example ----- import com.ozonetel.kookoo.Response; //add and import kookoo response.jar or source code into your application import com.ozonetel.kookoo.Dial; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @WebServlet(name = "testIvr", urlPatterns = {"/testIvr"}) public class testIvr extends HttpServlet { @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/xml;charset=UTF-8"); String event = request.getParameter("event"); Response r = new Response(); //create kookoo Response Object if ((null != event) && event.equalsIgnoreCase("NewCall")) { r.addPlayText("Please say your message after beep"); Dial dial = new Dial(); dial.setNumber("99xxxxxx"); // set number to dial r.addDial(dial); } else if ((null != event) && event.equalsIgnoreCase("Dial")) { String status = request.getParameter("status"); if (status.equalsIgnoreCase("answered")) { r.addPlayText("Dialled number is answered"); } else { r.addPlayText("Dialled number is not answered"); } r.addHangup(); } else { r.addPlayText("call is disconnecting "); r.addHangup(); } String kookooResponseOutput = r.getXML(); try (PrintWriter out = response.getWriter()) { out.println(kookooResponseOutput); } } }
api_key * | the API KEY of your account. This is so that you don't send your username and password over HTTP. You can find it in your dashboard once you login to www.kookoo.in |
phone_no * | The phone number to place the call to |
url | The url of your application |
extra_data | The initial XML action to perform.It could be something like <response><playtext>Some text to be played to the users</playtext><hangup/></response> |
outbound_version | value should be set to 2. This is the latest version and the older versions are deprecated. |
caller_id | Using this parameter, you can set your caller id if you have more than one phone number assigned to you. |
callback_url |
This is the URL which will be called after the call is finished. You can have your after call processing at this URL. We send the following parameters to this URL: 'sid' : A unique sequence ID. This will uniquely identify the call. 'caller_id' : The caller id which was set for this call 'phone_no' : The phone number which was called. 'duration': The duration of the call in seconds 'start_time': The start time of the call 'status': The status of the call.It currently has 'answered/ telco message ' |
Call Back Url Parameters | |
---|---|
sid | outbound-ucid, This is the link to the outbound request.It will be the same value which was returned in the xml for the outbound.php request |
status | 'answered/Reason for Not Connecting (Telco Message)' |
phone_no | 'Phone number of the dialed number' |
start_time | Call queued time |
ringing_time | Duration of call ring before answered |
duration | Answered call duration in seconds |
caller_id | Number, on which call is dialed |
dial_time | Call dialing time from the KooKoo Platform |
pick_time | The call picked time |
end_time | The call end time |
sip_causecode | (SIP Cause code) |
telco_code | message(In event Dial tag)/status(In Outbound CallBack URL) |
"0" | "Unknown" |
"1" | "InvalidNumber" |
"2" | "NoRouteNetwork" |
"3" | "NoRouteDestination" |
"4" | "SpecialTone" |
"5" | "MisdialedPrefix" |
"6" | "UnacceptableChannel" |
"7" | "BeingDelivered" |
"8" | "Preemption" |
"9" | "PreemptionReservedCircuit" |
"16" | "NormalCallClearing" |
"17" | "Busy" |
"18" | "NoResponse" |
"19" | "NoAnswer" |
"20" | "SubcriberAbsent" |
"21" | "Rejected" |
"22" | "NumberChanged" |
"26" | "NonSelectedUserClearing" |
"27" | "DestinationOutOfOrder" |
"28" | "InvalidNumberFormat" |
"29" | "FacilitiesRejected" |
"30" | "ResponseToStatusEnquiry" |
"31" | "NormalUnspecified" |
"34" | "Congestion" |
"35" | "CallQueuedAtServiceProvider" |
"38" | "NetworkOutOfOrder" |
"39" | "ConnnectionOutOfService" |
"40" | "permanentFrameMode" |
"41" | "TemporaryFailureAtServiceProvider" |
"42"=> | "SwitchingEquipmentCongestion" |
"43" | "AccessInformationDiscarded" |
"44" | "ChannelNotAvailable" |
"46" | "PrecedenceCallBlocked" |
"47" | "ResourceUnavailable" |
"49" | "QOSUnavailable" |
"50" | "FacilityNotSubscribed" |
"52" | "OutgoingCallBarred" |
"53" | "OutgoingCallBarredInCUG" |
"54" | "IncomingCallBarred" |
"55" | "IncomingCallBarredInCUG" |
"87" | "UserNotInCUG" |
"88" | "InComapatibleDestination" #incompatibledestination" |
"90" | "CUGNotPresent" #non-existentCUG" |
"91" | "InvalidTransistNetworkSelection" |
"95" | "InvalidMessage" |
"96" | "ElementIsMissing" |
"97" | "MessageNotImplemented" |
"98" | "messageNotCompatible" |
"99" | "ParameterNotExisted" |
"100" | "InvalidInformationElements" |
"101" | "messageNotCompatible" |
"102" | "RecoveryTimerOnExpiry" |
"103" | "NotImplemented" |
"110" | "MessageWithUnRecognigedParameter" |
"111" | "ProtocolError" |
"127" | "InterWorkingUnspecified" |
Ozonetel Cause code | message(In event Dial tag)/status(In Outbound CallBack URL) |
"200" | "DND_Number" |
"201" | "ISDDisabled" |
"203" | "OutboundDisabled" |
"204" | "MaxDialTimeExceeded" |
"205" | "user_disconnected" |
"9991" | "AcntMaxPortReached" |
"9992" | "QueueTimeExceeded" |
"9994" | "PRIBlocked" |
"9995" | "PRIDown" |
"9999" | "Exception" ( Internal KooKoo Issue ) |
KooKoo Outbound API Status and Message | Description |
<response><status>error</status><message>Outbound parameter extra_data or url is mandatory</message></response> | extraData is mandatory |
<response><status>error</status><message>Phone number is mandatory</message></response> | Phone Number is mandatory |
<response><status>error</status><message>Phone number is not in proper format</message></response> | Phone Number is not in particular format |
<response><status>error</status><message>DB Error</message></response> | If there is an internal API error. |
<response><status>error</status><message>Authentication error</message></response> | Not Provided valid details like callerID and apiKey |
<response><status>error</status><message>Phone number in DND list</message></response> | Phone Number is in DND |
<response><status>error</status><message>Calls will not be made between 9pm to 9am</message></response> | Can't call after between 9PM to 9 AM as per TRAI |
<response><status>error</status><message>Caller Id not valid</message></response> | callerID not provided properly |
<response><status>error</status><message>Telephony error</message></response> | Can't able to queue the call |
<response><status>error</status><message>Max Connections Reached</message></response> | Max Connections Reached (this will work if you use outbound_version=2) |
<response><status>queued</status><message>xxxxx</message></response> | if call is successfully queued |
<response><status>error</status><message>Credit limit exceeded</message></response> | Credit limit exceeded. |
Please Keep Watching this Space for more Updates......
<?php $url = 'http://www.kookoo.in/outbound/outbound.php'; $param = array('api_key' => 'KKfdbxxxxxxxx', 'phone_no' => '099xxxxxxxx', 'caller_id' => '91xxxxxxxx', 'outbound_version' => 2, 'url' => 'http://test.php' ); $url = $url . "?" . http_build_query($param, '&'); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 30); $result = curl_exec($ch); curl_close($ch); echo $result; // return $result; ?>
import java.net.URI; import org.apache.http.HttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.utils.URIBuilder; import org.apache.http.impl.client.BasicResponseHandler; import org.apache.http.impl.client.DefaultHttpClient; public class OutboundTest { public static void main(String a[]) { try { String url = "http://kookoo.in/outbound/outbound.php"; URIBuilder uribuilder = new URIBuilder(url); uribuilder.addParameter("api_key", "11111"); uribuilder.addParameter("phone_no", "91xxx"); uribuilder.addParameter("caller_id", "9140"); uribuilder.addParameter("outbound_version", "2"); uribuilder.addParameter("url", "http://x.yourhost/ivr.php"); URI uri = uribuilder.build(); System.out.println("Final Outboud API url " + uri); HttpGet httpget = new HttpGet(uri); DefaultHttpClient defaulthttpclient = new DefaultHttpClient(); HttpResponse outboundResponse = defaulthttpclient.execute(httpget); String responseString = new BasicResponseHandler().handleResponse(outboundResponse); System.out.println(responseString); } catch (Exception e) { e.printStackTrace(); } } }
<?php $url = 'http://www.kookoo.in/outbound/outbound_sms.php'; $param = array('api_key' => 'KKfdbxxxxxxxx', 'phone_no' => '099xxxxxxxx', 'message' => 'test message' ); $url = $url . "?" . http_build_query($param, '&'); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 30); $result = curl_exec($ch); curl_close($ch); echo $result; // return $result; ?>
import java.net.URI; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.utils.URIBuilder; import org.apache.http.impl.client.BasicResponseHandler; import org.apache.http.impl.client.HttpClientBuilder; public class OutboundSMS { public static void main(String a[]) { try { String url = "http://www.kookoo.in/outbound/outbound_sms.php"; URIBuilder uribuilder = new URIBuilder(url); uribuilder.addParameter("api_key", "11111"); uribuilder.addParameter("message", "test message"); uribuilder.addParameter("phone_no", "9140"); URI uri = uribuilder.build(); System.out.println("Final Outboud API url " + uri); HttpGet httpget = new HttpGet(uri); HttpClient client = HttpClientBuilder.create().build(); HttpResponse outboundResponse = client.execute(httpget); String responseString = new BasicResponseHandler().handleResponse(outboundResponse); System.out.println(responseString); } catch (Exception e) { e.printStackTrace(); } } }
<?php $files=array( 'http://www.test.com/sites/default/files/audio/1.wav', 'http://www.test.com/sites/default/files/audio/2.wav' ); foreach($files as $value) { $post_data['api_key'] ="KKXXXXXXXXXXXX"; $post_data['url'] = $value; echo $post_data['url']; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,"http://kookoo.in/restkookoo/index.php/api/cache/audio/"); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:')); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_VERBOSE, 1); $curl_scraped_page = curl_exec($ch); curl_close($ch); echo $curl_scraped_page; } ?>
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import org.apache.http.HttpResponse; import org.apache.http.NameValuePair; import org.apache.http.client.HttpClient; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.HttpPost; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.message.BasicNameValuePair; /** * * @author rajeshg */ public class CacheAPITest { public static void main(String a[]) { try { String audios[] = {"http://yourhost/generic/en/welcome_audio.wav", "http://yourhost/generic/en/thanks_audio.wav"}; String url = "http://kookoo.in/restkookoo/index.php/api/cache/audio/"; HttpClient client; HttpPost post; for (String audioUrl : audios) { client = HttpClientBuilder.create().build(); post = new HttpPost(url); List<NameValuePair> postParams = new ArrayList<>(); postParams.add(new BasicNameValuePair("api_key", "KKxxxxxx")); postParams.add(new BasicNameValuePair("url", audioUrl)); post.setEntity(new UrlEncodedFormEntity(postParams)); HttpResponse response = client.execute(post); System.out.println("Response Code : " + response.getStatusLine().getStatusCode()); BufferedReader rd = new BufferedReader( new InputStreamReader(response.getEntity().getContent())); StringBuilder result = new StringBuilder(); String line; while ((line = rd.readLine()) != null) { result.append(line); } System.out.println("kookoo api response" + result.toString()); } } catch (Exception e) { e.printStackTrace(); } } }
Parameter | Description |
sid | A unique identifier for this call, generated by KooKoo. You can use this to track your session state to move through the call flow. |
cid | The phone number of the party that initiated the call.This is nothing but the caller id. This will help your application to know who called your number. You can use this to compare the caller id in a database to identify the caller. KooKoo will try its best to send a 10 digit phone number but because of the different standards followed by our carriers it is best to test the different numbers that your application receives.This parameter will be sent only during the first request made by KooKoo. So make sure you store it for further reference. |
cid_e164 | Which gives you the correct international format (E.164) which is in a standard format. You can use this in your application . |
called_number | The KooKoo phone number that has been called.This is nothing but the DID.It will be useful if your application has more than one phone number associated with it and will help your application to know to which number the customer called. |
event | This will indicate to your application what event KooKoo handled just now. For example, if KooKoo just received a call, then it will populate this parameter with the value NewCall. Your application can use this parameter to react to different actions performed by KooKoo. The events supported by KooKoo right now are:
|
data | Generally there are different data associated with the KooKoo events. For example, once a recording is finished KooKoo returns the file name of the recorded file to your application. Similarly, after we collect user input, KooKoo returns the collected digits to your application for further processing. The different data sent by KooKoo for different events are:
|
callduration | This parameter is sent when the event is either "Record" or "Dial" or "Conference" and also when the event is in process like process ={"dial" or "Conference" or "record"} this generally comes when the event is in process and call gets disconnected. It specifies the amount of time the recording or dial happened. |
record_duration | This parameter is sent when the event is "Record" and when the call gets disconnected with particular event in process,then you get the duration with process parameter value as record. It specifies the amount of time the recording happened. |
total_call_duration | This parameter is sent when the event is "Hangup","Disconnect" or event "Hangup","Disconnect" with process ={"dial" or "Conference" or "record"}. It specifies the total time taken during the entire call. |
process | This parameter is sent when the call gets disconnected with particular event in process like {process=dial, process=conference, process=record, process=none} |
status | This parameter is sent when the event is "Dial". It specifies whether the dialed call was answered or unanswered. More info |
telco_code | This parameter is sent when the event is "Dial". When the Telco network or remote user disconnects a call for any reason.You can refer to the cause code and the same related details are provided in this site. . Click Here. KooKoo also sends you some codes which are sent in the same parameter.Currently we have these "200" => "DND_Number", "201" => "ISDDisabled", "202" => "Invalid_CallerId. |
outbound_sid | This parameter is sent when the event is "NewCall" and the call was generated through an outbound request. This will uniquely identify an outbound call. This is the connecting parameter from making an outbound request, to receiving the call on your IVR and after the call is finished in the callback url. So please use this to track the status of your call. |
circle | This parameter is sent when the event is "NewCall" and mentions the telecom circle of the caller. Using this, you can create an application that reacts differently based on the location(as per telecom circle) of the caller. List of possible values:
|
operator | This parameter is sent when the event is "NewCall" and mentions the telecom operator of the caller. Using this, you can create an application that reacts differently based on the operator of the caller. List of possible values:
|