This is one of the common requirements to failover SIP trunk or H323 trunk if ISDN status is down. The following configuration will shutdown SIP/H323 service on voice gateway once ISDN status changes to down. Also, it will start SIP/H323 services once the ISDN status changes to UP
Note that you need to change the interface (marked in red) based on your controller type (E1/T1) and controller number (0/0/0 or 0/0/01 etc). Also, this configuration is for SIP trunk but can be applied to H323 by changing the protocol marked in red.
event manager applet SHUTDOWN_SIP
event syslog pattern "Line protocol on Interface Serial0/0/0:15, changed state to down" period 1
action 1.0 cli command "enable"
action 1.1 cli command "config t"
action 1.2 cli command "voice service voip"
action 1.3 cli command "sip"
action 1.4 cli command "call service stop forced"
action 1.5 syslog msg "SIP Services Brought Down by EEM"
event manager applet BRING_UP_SIP
event syslog pattern "Line protocol on Interface Serial0/0/0:15, changed state to up" period 1
action 1.0 cli command "enable"
action 1.1 cli command "config t"
action 1.2 cli command "voice service voip"
action 1.3 cli command "sip"
action 1.4 cli command "no call service stop"
action 1.5 syslog msg "SIP Services Brought Up by EEM"