email messed call from queue

jsteel

New Member
Not sure if the OP is even following this thread anymore... I was originally thinking of a way to handle this through the dialplan but then came up with a much simpler idea of evaluating CDR data and capturing any cancel events during the http post event.

From the FS wiki for mod_callcenter: "If we get a hangup from the caller before talking to an agent, the CC-Cause will be 'Cancel'."

I added the bit of code below to v_xml_cdr_import.php and was able to receive an email notification if I called into a call center and then hangup before my call is answered. This was not tested in a production environment and would need more work so as not to hard code the email variables and would also need to handle multiple domains, but it did work as a proof of concept.

//if call center variable cc_cause == Cancel then send email notification
if (strlen($xml->variables->cc_clause) == "cancel") {
// Place code here to send an email notification
require_once "resources/phpmailer/class.phpmailer.php";
require_once "resources/phpmailer/class.smtp.php";
$mail = new PHPMailer;
//Enable SMTP debugging.
$mail->SMTPDebug = 3;
//Set PHPMailer to use SMTP.
$mail->isSMTP();
//Set SMTP host name
$mail->Host = "smtp.gmail.com";
//Set this to true if SMTP host requires authentication to send email
$mail->SMTPAuth = true;
//Provide username and password
$mail->Username = "xxxxxx@gmail.com";
$mail->Password = "xxxxxx";
//If SMTP requires TLS encryption then set it
$mail->SMTPSecure = "tls";
//Set TCP port to connect to
$mail->Port = 587;
$mail->From = "xxxxxx@gmail.com";
$mail->FromName = "Call Center PBX";
$mail->addAddress("xxxxxx@yahoo.com", "Name");
$mail->isHTML(false);
$mail->Subject = "Missed Call";
$mail->Body = "<i>A call was abandoned in the call center</i>";
$mail->AltBody = "This is the plain text version of the email content";
//Send the email and optionally save results to log or post to database
if(!$mail->send())
{
// Handle errors here
// echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
// echo "Message has been sent successfully";
}
}
 
Last edited:
Sorry for bringing this back from the dead. I tried jsteel's code and it does work. First thing is that I receive the email for each missed call in call center twice but I have no clue why. Then I am trying to modify it a bit so I can receive in the body of the email the number of the caller so I can call him back but every variable I use it returns empty.
For example I try in the body:
Code:
$mail->Body = "Missed Call from: " .strlen($xml->variables->effective_caller_id_number);
Whatever variable I put there it returns empty.

Any ideas?
 

jsteel

New Member
This is what is available for a cancel event. Taken from: https://freeswitch.org/confluence/display/FREESWITCH/mod_callcenter#EVENTS

Event-Subclass: callcenter::info
Event-Name: CUSTOM
CC-Queue: support@default
CC-Action: member-queue-end
CC-Member-Joined-Time: 9000
CC-Member-Leaving-Time: 10050
CC-Cause: Cancel
CC-Cancel-Reason: TIMEOUT
CC-Member-UUID: 453324f8-3424-4322-4242362fd23d
CC-Member-Session-UUID: e260ffd0-a731-11df-9341-e7d9456f8886
CC-Member-CID-Name: Marc O Robinson
CC-Member-CID-Number: 5145551212
 
I already tried with them as well but it returns 0 or 1, here is an example:
Code:
$mail->Body = "Missed Call from: " . strlen($xml->variables->CC-Member-CID-Number);
and result is:
Code:
Missed Call from: 1

I also made a couple more tests. Strange this is if I change the first if like this:
Code:
if (strlen($xml->variables->cc_clause) == "blahblah") {
I still get the email notification for the missed call.

Also if the available variable from cancel event is "CC-Cause" why in the first if it is "cc_clause"? Why the "l" character there?
 
Last edited: