A way to get notification for inbound route being hit?

Outbound routes have a great Notification option to send an email any time anything goes through that Outbound route. I’m trying to do something similar for Inbound routes – or, in some other way, send an email any time a call comes in.

To explain why… I have several FreePBX installations and everything is working great. I use Twilio as my SIP provider. What I do is set up a failover at Twilio so that if Twilio cannot connect to the primary FreePBX server, it connects to a failover server that I use for the several FreePBX installations. Basically, if the internet is down to a location, I want to handle any incoming calls in some way. All this failover server does is accept those incoming calls and either connect them to an emergency cell number or, for most, play a message that is the standard “The number you have reached is temporarily unavailable” sort of thing.

Again, this all works great – but what I want is to be notified if that failover server ever gets hit. Basically, if ANY call comes into that server, it means that something is broken somewhere else. So, I want it to email me if it gets any call (and then do the normal action for that call – such as calling a cell number or playing the “temporarily not in service” recording).

Any suggestions on how to go about doing that? Maybe a custom extension in extensions_custom.conf? Is that the best way?

I have not done this before, but if I were asked to implement this I’d make a custom context that sends the email, then pushes the call forward to the final destination based on the dnid.

The CID superfecta module has an item that sends email.


Ah! Very nice! I did not see that before. Seems to work well for what I want – thanks!


There are a few Superfecta ‘send to’ modules. I use Send to IFTTT in order to generate slack notifications of inbound calls.

I’ll use the CID Superfecta method most likely, but just for my own curiosity… I tried doing this with a custom extension with a modified extensions_custom.conf and can’t figure out how to get the Dialed Number into the email! Is there not a variable for that? I did something like this:

exten => s,1,NoOp(Entering user defined context  [send-email] in extensions_custom.conf)
exten => s,n,System(echo 'Incoming Call From: ${CALLERID(number)} - ${CALLERID(name)} to ${DNID}' | mail -s 'Alert' '[email protected]')
exten => s,n,hangup()

Everything works, except I can’t find a way to get the Dialed Number. ${DNID} is empty – and I saw that might be deprecated and to use ${CALLERID(dnid)} – which is also empty.

How do I get the Dialed Number to be emailed using a custom script?


Early in the inbound route call flow, the dialed number is set to the channel variable FROM_DID.

That worked. Thanks!

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