This is an old revision of the document!


A PCRE internal error occured. This might be caused by a faulty plugin

====== receive events ====== ===== Example: Generate CDR for an outbound call based on call events===== In this case, we will create a script cdrlog to generate CDR(call record details), the script will receive call events, based on these events we can create/update CDRs. The script is written in php and we use MySql database. * Call process: - Agent tell asterCC that I want to dial number XXXX - asterCC will originate a call to agent first, agent phone ring - Agent answers (legA) - asterCC will originate a call to number XXXX (legB) - (when agent answered)Customer phone ring(the call bridged, create a CDR) - Customer answered(call is answered, update CDR) - When agent or customer hangeup, the call is finished(call hangup, update CDR) * Scenario Analysis: An outbound call is that agent call customer, so we will know(when agent login) * Agent number $agentno * The phone number bind to the agent $agentphone * Team identity $orgidentity * Events: A complete call is composed by several events, they have same "sessionid" during the call, sessionid is the identity for a call <note tip>source+event could describe the call status</note> The script will process call events, when it receive a "ringing" event, it will create a new CDR, when receive another event, it will update the record <code> function cdr() { if($data ['calltype'] == ‘dialout’){ //outbound call event if($data['source'] == 'CALLEE' && $data['event'] == 'ringing'){ //agent dial out, customer ring, call start $src = (string)$agentphone; //legA, agent number $dst = (string)$data['activenum'];//dialed number $starttime = $data['eventTime'];//ringing time is start time $disposition = 'NOANSWER';//ringing means no answer yet $target = 'DialOut';//it's a outbound call $diallogid = $data['sessionid']; //identity of the call $agentno;//agent number $orgidentity;//team identity If(!(SELECT * FROM `your cdr table` WHERE diallogid=$diallogid limit 1;)){ //check if the record exists, if no, we create a new CDR, just in case we received duplicated events INSERT INTO `your cdr table` SET `variables above`;//save to database } }else if($data['source'] == 'CALLEE' && $data['event'] == 'answer'){ //customer answered, we need to update CDR $disposition = 'ANSWER';//update call status $answertime =$data['eventTime'];//update answered time UPDATE scenario WHERE diallogid=$diallogid limit 1; }else if($data['source'] == 'CALLEE' && $data['event'] == 'hangup'){ $endtime =$data['eventTime'];//end time UPDATE scenario WHERE diallogid=$diallogid limit 1; } } } </code> * config the url in astercc To receive call events for a team, you need to go to Team -> Advanced, "Push event URL:" = your script address, like http://192.168.0.100/cdr.php restart astercc daemons <code> /etc/init.d/asterccd restart </code>

en/custom_development_guide/apis/receive_call_events_via_http_post.1417059144.txt.gz · Last modified: 2017/12/12 03:11 (external edit)
Recent changes RSS feed Debian Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki