I am satisfied with that solution, but some users are not. The reason is that they also want to be notified when the caller hangs up before the ring time expires.
Current solution:
Incoming call --> No answer till ring time expires --> Custom destination is being triggered --> User gets email notification
What they additionally want:
Incoming call --> Caller hangs up before ring time expired --> User gets email notification or their softphone’s missed call list will enumerate missed calls while they were offline.
Has anybody ever implemented a solution for that requirement?
I have a few php scripts for doing things on events. I simplified one down to get you an idea.
Yealink includes “missed call” as an event.
<?php
// Put this script in /var/www/html/custom on your FreePBX.
// Then `fwconsole chown` to fix permissions
// Put this in the phone
// https://pbx.domain.com/custom/missedcall.php?call_id=$call_id&callerid=$callerID&local=$local&remote=$remote&display_local=$display_local&display_remote=$display_remote
// set to TRUE to log extra output to /var/log/messages
$debug = false;
// Get the info that was passed on the URL.
$call_id = $_GET["call_id"];
$callerid = $_GET["callerid"];
$local = $_GET["local"];
$remote = $_GET["remote"];
$display_local = $_GET["display_local"];
$display_remote = $_GET["display_remote"];
$callednumber = $_GET["callednumber"];
// log it if debug is set
($debug)?syslog(LOG_INFO,"missedcall.php values at load: call_id: ".$call_id." callerid: ".$callerid." local: ".$local." remote: ".$remote." display_local: ".$display_local." display_remote: ".$display_remote." callednumber: ".$callednumber):'';
// do stuff you want ot do here.
// for now, just write everything to a file to see what the fields are
$dt = new Datetime("now");
file_put_contents ("missedcall.log", "Begin Value Verification: \n", FILE_APPEND);
file_put_contents ("missedcall.log", "Timestamp: ".$dt->format('c')." \n", FILE_APPEND);
file_put_contents ("missedcall.log", "Yealink Phone Call ID: ".$call_id." \n", FILE_APPEND);
file_put_contents ("missedcall.log", "Caller ID Name from PBX: ".$callerid." \n", FILE_APPEND);
file_put_contents ("missedcall.log", "Received SIP URI (Callee): ".$local." \n", FILE_APPEND);
file_put_contents ("missedcall.log", "Received SIP URI (Caller): ".$remote." \n", FILE_APPEND);
file_put_contents ("missedcall.log", "Local Display Name (Callee): ".$display_local." \n", FILE_APPEND);
file_put_contents ("missedcall.log", "Caller ID Name from PBX (Caller): ".$display_remote." \n", FILE_APPEND);
file_put_contents ("missedcall.log", "Called Number (Caller): ".$callednumber." \n", FILE_APPEND);
file_put_contents ("missedcall.log", "End Value Verification \n", FILE_APPEND);
?>
That script dumps out this to a file. You can easily turn that into email.
Begin Value Verification:
Timestamp: 2020-11-06T10:33:36-06:00
Yealink Phone Call ID: 32783
Caller ID Name from PBX: St Louis, MO
Received SIP URI (Callee): sip:[email protected]
Received SIP URI (Caller): sip:[email protected]
Local Display Name (Callee): Jared Busch
Caller ID Name from PBX (Caller): St Louis, MO
Called Number (Caller): 3145551212
End Value Verification
We use Grandstream GXP 1630 and GXP 2170. But at remote offices they have only Softphone - we use PhonerLite. Thank you for your actionURL proposal and code. It is only relevant for deskphones, isn’t it?
Another work-around would be a script, which you execute as a cronjob every 5mins or so (you have to change the time span)
cdr-email.sh
#!/bin/bash
/usr/bin/mysql -u freepbxuser -PASSWORD -e "SELECT calldate AS Timestamp, clid AS Caller, disposition AS Status, dst AS Destination, duration AS Duration, src AS Source, did AS Target_inbound,lastapp AS LastApp,dcontext AS Context, dstchannel AS DestChannel, userfield AS outgoing, uniqueid AS ID from cdr where calldate > date_sub(now(), interval 24 HOUR) GROUP BY ID, Status ORDER BY ID DESC, Status DESC" -H asteriskcdrdb | mail -s "$(echo -e "Custom Call Report YOURLOCATION\nContent-Type: text/html")" YOUREMAILADDRESS
A while ago I wrote a dialplan which was called by a hangup handler that analyzed what happened to the call, such as if the call was a direct or queue, ring group or page call. Then it checked if the caller left a voicemail or not.
I abandoned that project, since I pushed the hangup handler via the predial hooks and there seems to be a bug which FreePBX doesn’t call the predial hook when calling offline PJSIP extensions. Also, IIRC I don’t think I was able to differentiate between a call coming from a ring group and a direct call.
So I think that Superfecta won’t be an option for us but thanks for the proposal to configure a scheduled database query. We will discuss this internally.