Notification for missed calls - part II


(Sip Sepp) #1

Hi, with great help by a power user in this thread [SOLVED] Questions to thread "Missed call notification" I managed that users get an email notification for missed calls.

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?

Thank you!


(Jared Busch) #2

It is called answering the phone when it is ringing.


(Sip Sepp) #3

Not possible when the user’s softphone is offline.


(Reinhard Stindl) #4

How many calls per day?

CID Superfecta can send you emails for every call, missed or not.


(Jared Busch) #5

How by setting up a destination for spam calls and setting the threshold to 0?

Never honestly looked into something like that because who wants that much email?

Edit: Oh, I found send to email…


(Jared Busch) #6

@sipsepp
What desk phones do these people have? Or are they softphone only?

Most modern desk phones have a Action setting where they can send info to URL on various events.

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:103@pbx.domain.com 
Received SIP URI (Caller): sip:3145551212@144.202.51.106 
Local Display Name (Callee): Jared Busch 
Caller ID Name from PBX (Caller): St Louis, MO 
Called Number (Caller): 3145551212 
End Value Verification 

(Sip Sepp) #7

Thank you, I will have a look into this.


(Sip Sepp) #8

Never heard about Superfecta. Seems to be a module for FreePBX. Will have a look into it.


(Sip Sepp) #9

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?


(Sip Sepp) #10

Can CID Superfecta’s send email function be restricted to send emails only for missed calls (so for answered calls no notification will be sent)?


(Reinhard Stindl) #11

No…CID Superfecta can do many things, but it does not know what happens to the call afterwards.


(Reinhard Stindl) #12

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

I described it here


(Itzik) #13

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.


(Sip Sepp) #14

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.


(system) closed #15

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.