Network Connectivity - Using the ${REASON} variable with a call file
Normally when a call initiated by a call file fails, it will simply be terminated. However, some customers would like to be able to handle the call differently, depending on the reason for failure. Because the call file does not enter the dialplan like a normal call issued from a phone, the ${REASON} channel variable must be used. It needs to be used in tandem with the special "failed" extension, which is where the call will go after the call file fails.
The ${REASON} variable has at least the following values:
0 - Failed (not busy or congested)
1 - Hung up
3 - Ring timeout
5 - Busy
8 - Congestion
Below is an example of how this might be used in the dialplan:
exten = failed,1,NoOp(The call failed)
exten = failed,n,GotoIf($[${REASON}=5]?busy)
exten = failed,n,GotoIf($[${REASON}=8]?congested)
exten = failed,n(congested),NoOp(The line was closed due to congestion)
;The appropriate steps to follow when a call fails due to congestion can be put here.
;[...]
exten = failed,n,Hangup()
exten = failed,n(busy),NoOp(The line was busy)
;The appropriate steps to follow when a call fails due to the line being busy can be put here.
;[...]
exten = failed,n,Hangup()