I have been learning asterisk dialplan and I have created a very simple IVR menu.I would like someone to verify that what I have created is correct.I want to create a very simple IVR with 2 menu levels and an exit option.
[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)
exten => 9,1,Hangup()
[main-menu]
exten => 456,1,Answer()
exten => 456,n,Background(main-menu)
exten => 3,1,Playback(digits/3)
exten => 3,n,Goto(incoming,456,1)
exten => 4,1,Playback(digits/4)
exten => 4,n,Goto(incoming,456,1)
exten => 9,1,Hangup()
I have created 2 context's above
[incoming] - to handle incoming calls [main-menu] - A menu option.
In the incoming context.I call the Answer() application when the extension is '123' Then it executes the background (main-menu).
if the user presses '1' it plays '1' and goes back to 123 priority '1'
if the user presses '2' it plays '2' and goes back to 123 priority '1'
if the user presses '9' it hangs up.
Similarly in [main-menu]
do I need an answer() in this context also?
I am just beginning to understand the dialplan and I am a bit confused at the moment.
So based on you suggestions my updated dialplan would look something like this.
[incoming]
exten => 123,1,Answer()
same => n(menuprompt),Background(main-menu)
exten => 1,1,Playback(digits/1)
same => n,Goto(menuprompt)
exten => 2,1,Playback(digits/2)
same => n,Goto(menuprompt)
exten => 9,1,Hangup()
[main-menu]
exten => n(menuprompt),Background(main-menu)
exten => 3,1,Playback(digits/3)
same => n,Goto(menuprompt)
exten => 4,1,Playback(digits/4)
same => n,Goto(menuprompt)
exten => 9,1,Hangup()
Thanks for the suggestions and explanations.But I have one question.
1) "main-menu" that is passed to the Background is is sound file apparently.In case of [incoming ] I want that to say something like
"press 1 to play 1"
"press 2 to play 2"
"press 9 to hangup"
where as in case of [main-menu] I want it to say something like
"press 3 to play 3"
"press 4 to play 4"
"press 9 to hangup"
Do I have to record that file.? How does that work?
Thanks in advance.