Hii…
I am starting a IVR, following is the code I have written up till now, the problem is it accepts but it doest send any thing.
This is the PHP page…
#!/usr/bin/php -q
<?PHP
require('/var/lib/asterisk/agi-bin/phpagi.php');
$agi = new AGI();
$agi->answer();
//required parameters and create variables
$systoken = "3pvUYhSgf/x0Wc+CDAI=";
$unique=$agi->request[agi_uniqueid];
$caller=$agi->request[agi_callerid];
$incoming=$agi->request[agi_dnid];
$texts = "";
$transferTos = "100";
//update variables
$data = array(
"systemToken" => "$systoken",
"uniqueCallId" => "$unique",
"callerNumber" => "$caller",
"incomingNumber" => "$incoming",
"text" => "$texts");
$data_string = json_encode($data);
//CRM endpoint
$ch = curl_init('http://liveasia.com/api/GetIvrResponse');
//create a new cURL resource
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
//execute post
$result = curl_exec($ch);
curl_close($ch);
$audio = json_decode($result, true);
//get variables
$audioPrompt = $audio["audioPrompt"]["text"];
$nextAction = $audio['nextAction'];
//play response recording
$agi->exec("AGI","live-tts.agi,\"$audioPrompt\",en");
?>
And this is the fiddler of the CRM…
When i given this command to it…
{“errorCode”:0,“nextAction”:“WaitForKeyPress”,“audioPrompt”:{“text”:“Thank you for calling HollywoodCars. Press 1 for immediate pickup at tesco kirkdale 151 kirkdale london. Press 2 for sainsburys supermarkets ltd22-24 market street huddersfield. Press 3 for 15 cross church street huddersfield. And for pick up at 8 chapel hill huddersfield please Press 4. or dial 0 for an operator”,“interruptible”:true},“maxDigits”:“1”,“wait”:“10000”}
Any heads up would be appreciated…
Jeet