Send Email or SMS notification for EVERY inbound hangup call

I am searching for a way to have FreePBX send out an Email or SMS for every inbound call who hangs up. I discovered on this board the suggestion below however, I am unable to get it to work.

It seems my hangup is knowing exactly where to put the suggested “local/s@send-email” line.

Does anyone have a better way to accomplish this task?


QUOTE

lgaetzLorne GaetzSangoma

If I was doing this, I would create a new context in /etc/asterisk/extensions_custom.conf with content similar to:

[send-email]
exten => s,1,NoOp(Entering user defined context [send-email] in extensions_custom.conf)
exten => s,n,System(echo ‘Call from ${CALLERID(name)} at ${CALLERID(number)}’ | mail -s ‘SUBJECT’ ‘[email protected]’)
exten => s,n,hangup()

Then in FreePBX create an extension of type, other (custom) device, give it a name and number. In the dial field use:

local/s@send-email

Now you have a local dummy extension that will execute custom code whenever it is dialed. You can include it in ring groups, or queues, etc. It will never answer the call, but whenever it rings it will execute the custom code. You have the basis for adding your own code for whatever you can dream up once you learn a bit of Asterisk.

edit - fixed system line quote

1 Like

The context

[macro-hangupcall]
include => macro-hangupcall-custom
exten => s,1(start),GotoIf($["${USE_CONFIRMATION}"="" | "${RINGGROUP_INDEX}"="" | "${CHANNEL}"!="${UNIQCHAN}"]?theend)
exten => s,n(delrgi),Noop(Deleting: RG/${RINGGROUP_INDEX}/${CHANNEL} ${DB_DELETE(RG/${RINGGROUP_INDEX}/${CHANNEL})})
exten => s,n(theend),Hangup
exten => s,n,MacroExit()

so create your context in extensions_custom.conf

[macro-hangupcall-custom]
exten => s,1,DumpChan()
exten => s,n,System(echo ‘Call from ${CALLERID(name)} at ${CALLERID(number)}’ | mail -s ‘SUBJECT’ ‘[email protected]’)
exten => s,n,MacroExit()

If you need to filter so not EVERY call is responded to, that would be where to do it also.

What triggers this macro into action?

It is run every time Macro(hangupcall) is called, that is pretty well everything, that’s why I included to DumpChan() call, you can look at the log files and filter as appropriate. possibly on ${HANGUPCAUSE}

Unfortunately, I am still unsure as to what exactly starts the macro. Is it called via a Custom Destination like “Lenny” (Telemarketer Torture)?

I don’t now how to answer more clearly, if you look at your dialplan you will see that almost invariably Macro(hangupcall) is called on a hangup, thusly if Macro(hangupcall) is called (it will be) then (if the dialplan has been reloaded, Asterisk has been restarted or you reboot the system) then every hungup call will ‘include’ first your custom code, then the default code.