B.17. ChanIsAvail()

Indicates whether the specified channel is available.
ChanIsAvail(technology1/resource1[&technology2/resource2...][,options])
Verifies that the one or more of the queried channels is available, in the order specified. Returns 0 on success or -1 on failure.
If the s (state) option is given, Asterisk will treat the channel as unavailable if it is in use, even if it is capable of taking another call. Option j sets priority jumping to n+101 if the channel is unavailable.

Note

The mere fact of a channel being available does not automatically mean that it is free for use or that the device on the channel will accept a call. That is determined using a Dial() to the channel.
ChanIsAvail() sets the following channel variables:
${AVAILCHAN}
The name of the accessible channel, including the session number of the call.
${AVAILORIGCHAN}
The canonical channel name (i.e., the channel name without session number).
${AVAILSTATUS}
Status code of the channel:
AST_DEVICE_UNKNOWN (0)
Status of the channel is unknown. It is a valid channel, but we don't know about its state.
AST_DEVICE_NOT_INUSE (1)
The channel is not in use.
AST_DEVICE_IN_USE (2)
The channel is in use.
AST_DEVICE_BUSY (3)
The channel is busy.
AST_DEVICE_INVALID (4)
The channel is unknown.
AST_DEVICE_UNAVAILABLE (5)
The channel is not available and not registered.
AST_DEVICE_RINGING (6)
The channel is ringing.

Note

This application does not behave as expected on MGCP channels.
; Check the availability of Zap/1 and Zap/2:
exten => 123,1,ChanIsAvail(Zap/1&Zap/2,j)
; As an exception, using priority jumping, because we want to announce
; something to the caller if no channel is available

; at least one channel is available - dial this channel:
exten => 123,2,NoOp(${AVAILORIGCHAN} is available)
exten => 123,3,Dial(${AVAILORIGCHAN}/123456)

; if the call goes to priority 102 landen, neither Zap/1 nor Zap/2 is available
exten => 123,102,Playback(all-channels-busy)

Note

Internal help for this application in Asterisk 1.4:
  -= Info about application 'ChanIsAvail' =- 

[Synopsis]
Check channel availability

[Description]
  ChanIsAvail(Technology/resource[&Technology2/resource2...][|options]): 
This application will check to see if any of the specified channels are
available. The following variables will be set by this application:
  ${AVAILCHAN}     - the name of the available channel, if one exists
  ${AVAILORIGCHAN} - the canonical channel name that was used to create the channel
  ${AVAILSTATUS}   - the status code for the available channel
  Options:
    s - Consider the channel unavailable if the channel is in use at all
    j - Support jumping to priority n+101 if no channel is available
diff output to internal help in Asterisk 1.2:
- none -