0
votes

Below are some asterisk dial plan examples that I have copied from somewhere.

exten => s,1,Answer()
exten => s,n,Playback(hello-world)
exten => s,n,Hangup()

The first line indicates when a new call comes into the channel it goes to extension s (top priority) 1 which is tied to the application Answer().

After that it goes to PlayBack(hello-world) and then the call is hung up.

Now the next section

[incoming]
exten => 123,1,Answer()
exten => 123,n,Background(main-menu)

exten => 1,1,Playback(digits/1)
exten => 1,n,Goto(incoming,123,1)

exten => 2,1,Playback(digits/2)
exten => 2,n,Goto(incoming,123,1)

Call is coming to extension 123.(Is this a new menu??) or is it forwarded from extension 's'.I think I am missing the connecting link here.

The second line says

exten => 123,n,Background(main-menu).

What is main-menu here? Where is it defined?

3

3 Answers

2
votes

Background is simililar to Playback application in that it plays file (main-menu is audio file that most likely would be found in /var/lib/asterisk/sounds/ directory).

While Playback plays the whole file before returning control. Background starts playing the file and returns control immediately so you can execute other commands.

For more information refer to:

voip-info.org - Playback and Background
wiki.asterisk.org - Playback and Background

[incoming]
exten => 123,1,Answer()

When asterisk receives incoming call on a channel, asterisk look at the context defined for that channel (incoming is the name of that context - usually the default context for incoming calls). The context has different commands depending on what extension the you have dialed.

If you have dialed 123 it will start playing some kind of automatic menu.

If you have dialed 1 or 2 it will play the digit and redirect again to 123 and start playing the interactive menu

1
votes

Call is coming to extension 123.(Is this a new menu??) or is it forwarded from extension 's'.

This is the Extension, comes from the default context (maybe default includes incoming or by channel definition). You could debug with a catchall exten, with

exten => _X.,1,NoOp(${CALLERID(NUM)} - ${EXTEN})

or

exten => 123,2,NoOp(${CALLERID(NUM)} - ${EXTEN})

and you see the Noop's when you're connected to the asterisk CLI.

$ asterisk -rvvv

What is main-menu here? Where is it defined?

main-menu is a Audio File like "main-menu.gsm" (the directory is defined in asterisk.conf). Asterisk decides which format/codec to use.

1
votes

One other thing is that the "next section"

[incoming]

... is a dialplan "context". Contexts are a way of partitioning your dialplan; it's a box that holds its own set of variable, extensions, etc.. So in your example, the first context does not explicitly "Goto" or "Gosub" the call to the "Incoming" context, so the call in the first context cannot go there.

As for how the call would get into the "incoming" context, quite often that is defined with the phone trunk coming into the system. So in your appropriate SIP, IAX2 or PSTN trunks, you would have a line like:

context=incoming

... and that would force the call to go there. If the call was "addressed" to extension 123 via a "DID" or "Direct Inwards Dial" number, then it would hit that extension and the caller would be hearing a menu greeting.