Question

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.

Was it helpful?

Solution

You're close, but not quite.

Think of contexts as physical boxes. You can't go through the walls in the box. So, "labels" and extensions only apply to what is in that one particular box / context.

In your updated dialplan, you would need to specifically Goto the context/extension/priority to get from one context to the other. That way the dialplan knows you aren't trying to refer to something inside the context it is already operating in.

With regards to message prompts you are playing, yes, you'll need to record those. MP3 format is the easiest to work with from the user perspective, but it puts a bit more load on the PBX. In this day and age of multi core gigahertz CPUs, I rarely worry about that.

If this is going to be a publicly facing system, consider your menu recordings to be the most important part of your system, from the customer POV. Messages with poor quality, low volume, difficult accents and such will "convince" your customer that your IVR is "too much work" to use.

OTHER TIPS

Your [incoming] context does exactly what you think it does.
You would only need to Answer() the line once ... before you start sending sound to the customer. So you would only need to Answer() in [main-menu] if you had not done it before.

Here is a slight re-write of [incoming] that would be a bit "better" in terms of readability and goof-proofing.

[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()

"Same" does exactly what it sounds like; "use the same extension as the line above". If you are doing large dialplans where you are doing a bit of cut-paste-tweak between different sections, such as IVRs, using "same" saves you from making an error with the extension number.

The "(menuprompt)" is called a label, and you can Goto labels within the same context, which absolves you of having to count "n"'s to figure out what priority number to use.

Further reading: https://wiki.asterisk.org/wiki/display/AST/Contexts,+Extensions,+and+Priorities

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top