Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
KooKoo Mixpanel final
<?php
require_once('response.php');// this is kookoo library. You can download it from KooKoo website.
$r= new Response();
//you will get the key after registering at mixpanel.
$metrics = new MetricsTracker("your_mixpanel_api_key");
if($_REQUEST['event'] == 'NewCall')
{
//get the phone number of the person who called
$caller_id=$_REQUEST['cid'];
$_SESSION['cid']=$caller_id;
//adding a called event to mixpanel
$metrics->track('called',array('distinct_id'=>$caller_id));
//get the deals for the categories chosen by the caller.getDealsForCustomer is the function
//which gets details from your database.
$deal=getDealsForCustomer($caller_id);
$cd= new CollectDtmf();
//playback the deals and hangup
$cd->addPlayText('Please press 1 for '.$deal[0]);
$cd->addPlayText('Please press 2 for '.$deal[1]);
$r->addCollectDtmf($cd);
$r->send();
}
else if($_REQUEST['event']=='GotDtmf')
{
$digit=$_REQUEST['data'];
if($digit == '1')
{
$r->addPlayText('Thanks for choosing deal 1');
//adding mixpanel event for deal 1
$metrics->track('purchase',array('name'=>'deal1','distinct_id'=>$_SESSION['cid']));
//do payment processing
}
else if($digit == '2')
{
$r->addPlayText('Thanks for choosing deal 2');
//adding mixpanel event for deal 2
$metrics->track('purchase',array('name'=>'deal1','distinct_id'=>$_SESSION['cid']));
}
$r->addHangup();
$r->send();
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.