|Help Centre

Prove your value

Last updated at

In this example, we assume that you are already a partner to Freespee with web access to the Freespee Dashboard interface. We also assume that you have created some customers and some sources to track calls to your customers simply. Now you want to move into proving your value to your customers by creating your own reports based on calls to these sources.

1. Fetch a customer

Since you have already added your own customers into Freespee Dashboard, we can use your internal customer ID to fetch the corresponding customer record from Freespee Dashboard (you could skip this step since /statistics/cdrs also support the custnr parameter):

GET /customers?custnr=1412
{
 "customers":[{
  "customer_id":"407382",
  "name":"DailyLoans",
  "custnr":"1412","corporateid":"",
  "email":"",
  "uuid":"0097bfcb-9c9c-45ae-b811-2dcc3e799100",
  "dncs_class_name":"",
  "receive_monthly_report":"0",
  "freespee_caller_id":"0"
 }]
}

2. Fetch call data records

Cool, let's fetch all calls made to the customer named “DailyLoans” during 2011-10-20. Now we will access the /statistics/cdrs resource to get each call and its details from the API:

GET /statistics/cdrs?customer_id=407382&from_date=2011-10-20&to_date=2011-10-21
{
 "total":5,
 "page":0,
 "pagesize":1000,
 "numpages":1,
 "cdrs":[{
  "cdr_id":"816010",
  "start":"2011-10-20 11:29:42",
  "duration":"0",
  "anum":"+46735177xxx",
  "bnum":"+46812345678",
  "cnum":"+46890510",
  "customer_id":"407382",
  "source_id":"643942",
  "custnr":"bca1412",
  "answered":"0",
  "anum_ndc_name":"Sweden, Mobile"
 },{
  "cdr_id":"816011",
  "start":"2011-10-20 11:29:55",
  "duration":"8",
  "anum":"+46735177xxx",
  "bnum":"+46812345678",
  "cnum":"+46890510",
  "customer_id":"407382",
  "source_id":"643942",
  "custnr":"bca1412","answered":"1",
  "anum_ndc_name":"Sweden, Mobile"
 },{
  "cdr_id":"816012",
  "start":"2011-10-20 11:37:40",
  "duration":"10",
  "anum":"",
  "bnum":"+46812345678",
  "cnum":"","customer_id":"407382",
  "source_id":"643943",
  "custnr":"bca1412",
  "answered":"1",
  "anum_ndc_name":null
 },{
  "cdr_id":"816014",
  "start":"2011-10-20 11:54:12",
  "duration":"12",
  "anum":"+46735177xxx",
  "bnum":"+46812345678",
  "cnum":"+46890510",
  "customer_id":"407382",
  "source_id":"643943",
  "custnr":"bca1412",
  "answered":"1",
  "anum_ndc_name":"Sweden, Mobile"
 },{
  "cdr_id":"816015",
  "start":"2011-10-20 13:25:54",
  "duration":"10",
  "anum":"+46735177xxx",
  "bnum":"+46812345678",
  "cnum":"+46890510",
  "customer_id":"407382",
  "source_id":"643956",
  "custnr":"bca1412",
  "answered":"1",
  "anum_ndc_name":"Sweden, Mobile"
 }]
}

Ok, so what just happened here? We got a list of 5 calls made to this customer during 2011-10-20. Sweet! Some of these calls have answered=0. It is unanswered calls (or missed calls). Others are answered=1, which means that the customer picked up the call. With some PHP-code we can easily do an aggregation with this data ($input is the JSON data from above):

<?php $calls = json_decode($input);
 
$answered = 0;
$unanswered = 0;
foreach ($calls->cdrs as $k => $v) {
 if ($v->answered == 0) { $unanswered++; }
 if ($v->answered == 1) { $answered++; }
}
 
printf ("Customer DailyLoans have had %s answered calls and %s unanswered calls.", $answered, $unanswered);
?>

This would result in:

Customer DailyLoans have had 4 answered calls and 1 unanswered calls.

That's the basics. Now you are ready to start creating your own customised reports! Happy coding!

Can't find what you're looking for?