Saturday, February 11, 2012

Asterisk Dialplan - Building an Interactive Dialplan

The Background(), WaitExten(), and Goto Applications
The Background() is similar to Playback() application, takes the same argument, the difference is Background() will stop and process the press callers enter digit. Norally used for voice menus (auto-attendants or phone trees).
exten => 212, 1, Answer()
exten => 212, n, Background(main-menu)
exten => 212, n, WaitExten() ;Normally follows after Background(), wait for the caller to enter DTMF digits.
WaitExten(5) means waiting for 5 seconds.
Goto Syntax: Goto(context, extension, priority)

Example:
[incoming]
exten => 212, 1, Answer()
exten => 212, n, Background(main-menu)
exten => 212, n, WaitExten(5)

exten => 1, 1, Playback(digit/1)
exten => 1, n, Goto(incoming, 212, 1)

Handling Invalid Entries and Timeouts
i extension and t extension
Example:
[incoming]
exten => 212, 1, Answer()
exten => 212, n, Background(main-menu)
exten => 212, n, WaitExten(5)

exten => 1, 1, Playback(digit/1)
exten => 1, n, Goto(incoming, 212, 1)

exten => i, 1, Playback(invalid-digit)
exten => i, n, Goto(incoming, 212,1)

exten => t, 1, Playback(invalid-digt)
exten => t, n, Hangup()

Dial() Application takes up to four arguments.
The first is the destination you are attempting to call, which is made up of a technology across which to make the call, a forward slash, and the remote endpoint or resource. Common technology types include Zap (for analog and T1/E1/J1 channels), SIP, and IAX2.
For example, let's assume that we want to call a Zap endpint identified by Zap/1, which is an FXS channel with an analog phone plugged into it. The technology is Zap, and the resource is 1. Similarly, a call to a SIP device (as defined in sip.conf) might hava a destination of SIP/Jane, and a call to an IAX defice (defined in iax.conf) might have a destination of IAX2/Fred. If we wanted Asterisk to ring the Zap/1 channel when extension 212 is reached in the dialplan, we'd add the following extension:
exten => 212, 1, Dial(Zap/1)
To dial multiple channels at the same time, by concatenating the destinations with an ampersand (&):
exten => 212, 1, Dial(Zap/1&Zap/2&SIP/Jane)

The Dial() application also allows you to connect to a remote VoIP endpoint not previously defined in one of the channel configuration files. Syntax is:
Dial(technology/user[:password]@remote_host[:port][/remote_extension])
The full syntax for the Dial() application is slightly different when dealing with Zap channels:
Dial(Zap/channel_or_group/remote_extension)
For example, here is how you would dial 01263123456 on Zap channel number 1
exten => 200,1,Dial(Zap/1/01263123456)

The second argument to the Dial() application is a timeout, specified in seconds.
exten => 212, 1, Dial(Zap/1, 10)
exten => 212, n, Playback(vm-nobodyavail)
exten => 212, n, Hangup()

The third arguement to Dial() is an option string. (m for music-on-hold)
The fourth argument to the Dial() application is a URL.

No comments:

Post a Comment