Re-route calls based on sip peer availability

Trying to automate a fix for an issue I have. I’ve moved my freepbx distro to a cloud based server. When I used to have it on local hardware and my internet would go down, my sip provider would detect the PBX was offline and automatically failover calls to my cell.

Now that the pbx is in the cloud it never goes offline so if my local internet is down calls will just go to voicemail instead of being re-routed to the failover number (as this is a function of the sip provider).

I’m wondering if there is a way (a script perhaps) that I could detect if all the sip peers were offline and forward all inbound calls to an external number?

Each extension has a Not Reachable destination that you could set to a Misc Destination that rings a mobile.

However, I don’t know how this would interact with Ring Groups, Queues or other means of ringing the extension.

Ring Groups and Queues will not call “unavailable” devices. If they are in that state it just doesn’t attempt it.

OK, so then a Ring Group with all devices unavailable would take the Destination if no answer path right away, which you could route to a mobile? Then, you would include in the group e.g. a delayed Follow Me to voicemail, so when the system was working normally but no one answered, calls would go to the selected voicemail box.

Correct, Ring Groups (and things like Follow-Me) call on the dialparties.agi script which will check the status of the RG members based on the RG settings and check if they are unavailable, etc. It will then build and dial the members via Local channels. If the AGI exits with no parties to dial, it sends the call to the failover destination.

Added: The AGI can exit with no parties to dial and still have every member “available/registered” if all of the members meet “no dial” requirements like with CW/BUSY, etc. Same behavior, will go to the failover destination.

thanks for the replies guys, interesting solutions although I’m not sure how reliable the delayed follow me would be in this situation. Honestly, I’m not even sure how to incorporate a delayed follow me into a ring group.

If you prefer using a script, that shouldn’t be hard. For example ping the office IP address every 10 seconds; if six failures in a row consider it down. Then, when it starts responding again, consider it up. Using a Call Flow Control in your routing, you could set or clear that programmatically with e.g.
asterisk -rx "database put DAYNIGHT C0 NIGHT"

Sterwart1, yeah that’s more along the lines of what I’m looking for. So basically run all calls through a call flow control that the script toggles on/off based on the ping responses from the location.

Now… to learn scripting with asterisk :slight_smile:

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