Script to monitor call failures NOT TRUNK

We use FreePBX 12.0.63. We have many Inbound Routes that pass calls to ring groups that consist of both internal and external numbers. Last night we had one of our carriers stop accepting calls from us. Is there some sort of script I can run that will email me when a call actually fails. In the ring group on failure I see I can have it set to play a recording but I would love an email when this happens so it can be proactively worked on and not wait 5+ hours before someone notices.

In the ring group, on failure can you send to a custom destination rather than a recording? If you can, then you can probably create a bit of dialplan in extension_custom.conf to send the email. This is untested but I think something like this would work:

exten => s,1,TrySystem(echo "Call failure at ${STRFTIME(${EPOCH},,%l:%M:%S %p %Z on %A %B %e)}" | mail [email protected])
exten => s,n,Return

Then make a custom destination pointing to custom-failure-notify,s,1 and check the “Return” box and then set the destination as your recording. If you don’t see the “Return” box, upgrade the Custom Applications module to the latest version. Then instead of setting the failure destination to the recording, set it to this custom destination.

Of course you’ll change the email address to your real email, and change the text to include whatever information you want within reason. You can use Asterisk variables such as the ${EPOCH} variable shown in the example to make the message more informative, but that’s up to you. This is just an example to get you started.

Thank you very much. This definitely got me going in the right direction.