The problem with multilevel IVRs is that the caller has to enter
single digits multiple times (oftentimes the same digit), but gets a
different response depending on the menu level. Because a number can only
be used once in a given context, the caller would be stuck on the first
menu level. If we need multiple menus which provide different responses
for the same digits, we must place the submenus in different contexts
([cafeteria] in our example). We jump between these contexts
using the application Goto()
(see the section called “Goto()”). Let's assume you have the
following sound files stored in
/var/lib/asterisk/sounds/:
mainmenu.gsm
"Press 1 for sales, 2 for service, or 3 for the cafeteria."
cafeteria.gsm
"Press 1 to hear the menu for this week or 2 to hear the menu for next week."
cafeteria-menu-this-week.gsm
"Monday: Noodles with pesto sauce. Tuesday: Pork chops..."
cafeteria-menu-next-week.gsm
"Monday: Stew, featuring noodles, basil and, um, pork chops..."
If sales is at extension 100 and the service department is at 150, the dialplan for this IVR would look like this:
[example-ivr] ; The menu is repeated until the caller provides input. ; exten => 30,1,Answer() exten => 30,2,Background(mainmenu) exten => 30,3,Background(silence/3) exten => 30,4,Goto(2) exten => 1,1,Dial(SIP/100) exten => 2,1,Dial(SIP/150) ; Goto() jumps to another context ([cafeteria]) ; exten => 3,1,Goto(cafeteria,100,1) exten => i,1,Goto(30,2) [cafeteria] exten => 100,1,Background(cafeteria) exten => 100,2,Background(silence/3) exten => 100,3,Goto(1) exten => 1,1,Playback(cafeteria-menu-this-week) exten => 1,2,Wait(2) exten => 1,3,Goto(1) exten => 2,1,Playback(cafeteria-menu-next-week) exten => 2,2,Wait(2) exten => 2,3,Goto(1) ; Invalid input sends the caller back to the main menu exten => i,1,Goto(example-ivr,30,2)