$collectInput->setTimeOut('4000');
    //maxtimeout if caller not give any inputs
    $collectInput->setTermChar('#');
    $r->addCollectDtmf($collectInput);
    $_SESSION['next_goto'] = 'conference';
} else {
    if ($_REQUEST['event'] == "GotDTMF" && $_SESSION['next_goto'] == 'conference') {
        if ($_REQUEST['data'] == "") {
            $collectInput = new CollectDtmf();
            $collectInput->addPlayText("You have not given any input");
            $collectInput->addPlayText('please enter the conference number again followed by hash', 3);
            $collectInput->setMaxDigits('4');
            //max inputs to be allowed
            $collectInput->setTimeOut('4000');
            //maxtimeout if caller not give any inputs
            $collectInput->setTermChar('#');
            $r->addCollectDtmf($collectInput);
            $_SESSION['next_goto'] = 'conference';
        } else {
            if ($_REQUEST['data'] == $confno[0]) {
                $r->addPlayText("Please be online while we connect you. Thank you");
                $r->addConference($confno[0]);
            } else {
                $r->addPlayText("Your input has been not matched with any our conference numbers");
            }
        }
    }
}
$r->send();
?>
 
    $collectInput->addPlayText('Welcome to Koo Koo. Are you new to place?', 4);
    $collectInput->addPlayText('press 1 for entering location, press 2 for nearby places, press 3 for weather details', 4);
    $collectInput->setMaxDigits('1');
    //max inputs to be allowed
    $collectInput->setTimeOut('4000');
    //maxtimeout if caller not give any inputs
    $r->addCollectDtmf($collectInput);
    $_SESSION['next_goto'] = 'Menu1_CheckInput';
} else {
    if ($_REQUEST['event'] == 'GotDTMF' && $_SESSION['next_goto'] == 'Menu1_CheckInput') {
        //input will come data param
        //print parameter data value
        if ($_REQUEST['data'] == '') {
            //if value null, caller has not given any dtmf
            //no input handled
            $r->addPlayText('you have not entered any input');
            $_SESSION['next_goto'] = 'Menu1';
        } else {
            if ($_REQUEST['data'] == '1') {
                $_SESSION['next_goto'] = 'Record_Status';
                $r->addPlayText('Please enter your location after beep ');
                //give unique file name for each recording
                $r->addRecord('filename2', 'wav');
            } else {
                if ($_REQUEST['data'] == '2') {
                    $_SESSION['next_goto'] = 'DialMenu';
                } else {
                    if ($_REQUEST['data'] == '3') {
                        $_SESSION['next_goto'] = 'Dial1_Status';
                    } else {
                        $r->addPlayText('Thats an invalid input');
    $collectInput->setTermChar('#');
    $r->addCollectDtmf($collectInput);
    $_SESSION['next_goto'] = 'check_pin';
} else {
    if ($_REQUEST['event'] == "GotDTMF" && $_SESSION['next_goto'] == 'check_pin') {
        if ($_REQUEST['data'] == "") {
            $collectInput = new CollectDtmf();
            $collectInput->addPlayText('You have not given any input', 3);
            $collectInput->addPlayText('please enter the pin again', 3);
            $collectInput->setMaxDigits('4');
            //max inputs to be allowed
            $collectInput->setTimeOut('4000');
            //maxtimeout if caller not give any inputs
            $collectInput->setTermChar('#');
            $r->addCollectDtmf($collectInput);
            $_SESSION['next_goto'] = 'check_pin';
        } else {
            if ($_REQUEST['data'] == $store[0]) {
                $r->addPlayText("Welcome to YourCompany");
                //your code here
            } else {
                $r->addPlayText("The pin you entered is wrong");
                $r->addHangup();
                //call disconnects at this stage
            }
        }
    }
}
$r->send();
?>
 
<?php

//Description:Sample Code to playback a dynamic text
session_start();
require_once "response.php";
//response.php is the kookoo xml preparation class file
$r = new Response();
$languages = array("Press 1 for English", "Press 2 for Hindi", "Press 3 for Kannada");
//Declaration of array consisting three values
if ($_REQUEST['event'] == "NewCall") {
    foreach ($languages as $key => $value) {
        $r->addPlayText($value);
    }
}
$r->send();
?>
 
    $collectInput->addPlayText('welcome to koo koo', 4);
    $collectInput->addPlayText('press 1 for record, press 2 dial, press 3 for conference test, press 4, for other', 4);
    $collectInput->setMaxDigits('1');
    //max inputs to be allowed
    $collectInput->setTimeOut('4000');
    //maxtimeout if caller not give any inputs
    $r->addCollectDtmf($collectInput);
    $_SESSION['next_goto'] = 'Menu1_CheckInput';
} else {
    if ($_REQUEST['event'] == 'GotDTMF' && $_SESSION['next_goto'] == 'Menu1_CheckInput') {
        //input will come data param
        //print parameter data value
        if ($_REQUEST['data'] == '') {
            //if value null, caller has not given any dtmf
            //no input handled
            $r->addPlayText('you have not entered any input');
            $_SESSION['next_goto'] = 'Menu1';
        } else {
            if ($_REQUEST['data'] == '1') {
                $_SESSION['next_goto'] = 'Record_Status';
                $r->addPlayText('Please record your message after beep ');
                //give unique file name for each recording
                $r->addRecord('filename2', 'wav', '120');
            } else {
                if ($_REQUEST['data'] == '2') {
                    $_SESSION['next_goto'] = 'DialMenu';
                } else {
                    if ($_REQUEST['data'] == '3') {
                        $r->addPlayText('your conference number is 1 2 3 4 ');
                        $r->addConference(1234);
                        $_SESSION['next_goto'] = 'Dial1_Status';
<?php

/*Description:Using a record tag you get below request parameters from kookoo in response. * event =Record * data =Recorded file_URL * status =Record Status*/
session_start();
//start session, session will be maintained for entire call
require_once "response.php";
//response.php is the kookoo xml preparation class file
$r = new Response();
if ($_REQUEST['event'] == "NewCall") {
    $r->addPlayText('Please record your message after beep ');
    //give unique file name for each recording
    $r->addRecord('filename2', 'wav', '120');
    $_SESSION['next_goto'] = 'Record_Status';
} else {
    if ($_REQUEST['event'] == 'Record' && $_SESSION['next_goto'] == 'Record_Status') {
        //recorded file will be come as  url in request parameter called data
        $r->addPlayText('your recorded audio is ');
        //You can also store the URL in your database if you want
        $_SESSION['record_url'] = $_REQUEST['data'];
        $r->addPlayAudio($_SESSION['record_url']);
        $r->addPlayText('Thank you for calling, have a nice day');
        $r->addHangup();
    }
}
$r->send();
?>
 
$store = array(9704);
// declaration of array
if ($_REQUEST['event'] == "NewCall" || $_SESSION['next_goto'] == 'restart') {
    $collectInput = new CollectDtmf();
    $collectInput->addPlayText('please enter the pin', 3);
    $collectInput->setMaxDigits('4');
    //max inputs to be allowed
    $collectInput->setTimeOut('4000');
    //maxtimeout if caller not give any inputs
    $collectInput->setTermChar('#');
    $r->addCollectDtmf($collectInput);
    $_SESSION['next_goto'] = 'check_pin';
} else {
    if ($_SESSION['next_goto'] == 'check_pin') {
        if ($_REQUEST['data'] == "") {
            $r->addPlayText("You have not given any input");
            $_SESSION['next_goto'] = 'restart';
        } else {
            if ($_REQUEST['data'] == $store[0]) {
                $r->addPlayText("Welcome to YourCompany");
                //your code here
            } else {
                $r->addPlayText("The pin you entered is wrong");
                $r->addHangup();
                //call disconnects at this stage
            }
        }
    }
}
$r->send();
?>
    $collectInput->addPlayText('please enter the number that you want to dial followed by hash, if it is s t d number, enter 0 as pre fix ', 3);
    $collectInput->setMaxDigits('15');
    //max inputs to be allowed
    $collectInput->setTimeOut('4000');
    //maxtimeout if caller not give any inputs
    $collectInput->setTermChar('#');
    $r->addCollectDtmf($collectInput);
    $_SESSION['next_goto'] = 'Menu1_CheckInput1';
} else {
    if ($_REQUEST['event'] == 'GotDTMF' && $_SESSION['next_goto'] == 'Menu1_CheckInput1') {
        //input will come in data param
        //print print parameter data value
        if ($_REQUEST['data'] == '') {
            //if value null, caller has not given any dtmf
            //no input handled
            $r->addPlayText('you have not entered any input');
            $_SESSION['next_goto'] = 'Menu1';
        } else {
            $_SESSION['dial'] = $_REQUEST['data'];
            $r->addPlayText('please wait while we transfer your call to out customer care');
            $r->addDial($_SESSION['dial'], 'true', 1000, 30, 'ring');
            $_SESSION['next_goto'] = 'Dial1_Status';
        }
    } else {
        if ($_REQUEST['event'] == 'Dial' && $_SESSION['next_goto'] == 'Dial1_Status') {
            //dial url will come in data param  //if dial record is false then data value will be -1 or null
            //dial status will come in status (answered/not_answered) param
            $_SESSION['dial_record_url'] = $_REQUEST['data'];
            $_SESSION['dial_status'] = $_REQUEST['status'];
            $_SESSION['dial_callduration'] = $_REQUEST['callduration'];
            if ($_REQUEST['status'] == 'not_answered') {
session_start();
$r = new Response();
if ($_REQUEST['event'] == "NewCall") {
    $cd = new CollectDtmf();
    $cd->setTermChar("#");
    $cd->setTimeOut("4000");
    $cd->addPlayText("welcome to adder.Please enter your first number.Terminate with hash");
    $r->addCollectDtmf($cd);
    $_SESSION['state'] = "firstNumber";
    $r->send();
} else {
    if ($_REQUEST['event'] == "GotDTMF" && $_SESSION['state'] == "firstNumber") {
        $first = $_REQUEST['data'];
        $cd = new CollectDtmf();
        $cd->setTermChar("#");
        $cd->setTimeOut("4000");
        $cd->addPlayText("Please enter the Second number.Terminate with hash");
        $_SESSION['firstNumber'] = $first;
        $_SESSION['state'] = "secondNumber";
        $r->addCollectDtmf($cd);
        $r->send();
    } else {
        if ($_REQUEST['event'] == "GotDTMF" && $_SESSION['state'] == "secondNumber") {
            $second = $_REQUEST['data'];
            $total = $_SESSION['firstNumber'] + $second;
            $r->addPlayText("your total is {$total}");
            $r->addHangup();
            $r->send();
        }
    }
}
Example #10
0
include "php/db.php";
session_start();
require_once "response.php";
//include KooKoo library
$r = new Response();
//create a response object
$cd = new CollectDtmf();
if (isset($_REQUEST['event']) && $_REQUEST['event'] == 'NewCall') {
    $no = $_REQUEST['cid'];
    $result = mysqli_query($conn, "select * from user where  mobile='{$no}' ");
    $row_cnt = $result->num_rows;
    $row = mysqli_fetch_assoc($result);
    $userid = $row['id'];
    if ($row_cnt == 0) {
        $r->addPlayText("Sorry. This number is not registered. Thank you for calling, have a nice day");
        $postdata = "name=Audiochat&no=" . $no . "&msg=register at audiochat.azurewebsites.net  ";
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, 'http://faltusms.tk/sendSms.php');
        curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($ch, CURLOPT_VERBOSE, 1);
        curl_setopt($ch, CURLOPT_TIMEOUT, 60);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
        curl_setopt($ch, CURLOPT_POST, 1);
        $result = curl_exec($ch);
        $r->addHangup();
        $r->send();
        exit;
Example #11
0
    //
    //You maintain your own session params store require data
    $_SESSION['caller_number'] = $_REQUEST['cid'];
    $_SESSION['kookoo_number'] = $_REQUEST['called_number'];
    //called_number is register phone number on kookoo
    //
    $_SESSION['session_id'] = $_REQUEST['sid'];
    //sid is unique callid for each call
    // you maintain one session variable to check position of your call
    //here i had maintain next_goto as session variable
    $_SESSION['next_goto'] = 'Menu1';
    $_SESSION['menu'] = 0;
    $_SESSION['cat'] = 0;
    $_SESSION['sub_cat'] = 0;
    $_SESSION['sub_sub_cat'] = 0;
    $r->addPlayText('welcome to koo koo e commerce platform. ', 4);
}
if ($_REQUEST['event'] == "Disconnect" || $_REQUEST['event'] == "Hangup") {
    //when users hangs up at any time in call  event=Disconnect
    // when applicatoin sends hangup event event=Disconnect
    //if users hang up the call in dial event you will get data ans status params also
    //$_SESSION['dial_record_url']=$_REQUEST['data'];
    //$_SESSION['dial_status']=$_REQUEST['status'];
    exit;
}
if ($_SESSION['next_goto'] == 'Menu1') {
    $collectInput = new CollectDtmf();
    $collectInput->addPlayText('Please choose category', 4);
    for ($i = 0; $i < count($category[$_SESSION['menu']][$_SESSION['cat']][$_SESSION['sub_cat']]); $i++) {
        $collectInput->addPlayText("Press " . $i . " for " . $category[$_SESSION['menu']][$_SESSION['cat']][$_SESSION['sub_cat']][$i] . ", ", 4);
    }