Change destination based on SIP endpoint status

Here’s what I’d like to do:

When an incoming call comes in, check the status (as seen in Reports / Asterisk Info / Peers) of a certain SIP extension.

If the status is “OK” go to destination 1 (i.e. a RingGroup or IVR).

If the status is “UNKNOWN” (or anything other than OK), go to destination 2 (i.e. a MiscDestination with a cell phone number).

I don’t want someone to do the work for me, just point me in the right direction. I’d like to eventually write a custom module that does this, similar to the way a Time Condition works.

You can basically do this in the extension page. At the bottom of the page for each extension you can set a optional destination for Not Reachable which only gets used when the phone is not registered with Asterisk

That would work if my original destination was a single Extension, but my Incoming Routes point to Ring Groups or IVRs, where that is (currently) not an option.