Asterisk : Creating a Simple IVR Menu
[demo-menu]
exten => s,
1
,Answer(
500
)
same => n(loop),Background(press-
1
&or&press-
2
)
same => n,WaitExten()
exten =>
1
,
1
,Playback(you-entered)
same => n,SayNumber(
1
)
same => n,Goto(s,loop)
exten =>
2
,
1
,Playback(you-entered)
same => n,SayNumber(
2
)
same => n,Goto(s,loop)
[from-pstn]
exten =>
6598
,
1
,Goto(demo-menu,s,
1
)
[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)
exten => t,1,Goto(i,1) ; If they take too long, give up means time out
exten => i,1,Background(session-timeout) ; “Invalid choice” invallid choice
[ivr-menu]
exten => s,1,Answer()
same => n(loop),Background(menuselect)
same => n,WaitExten()
exten => 1,1,Playback(youselect)
same => n,SayNumber(1)
same => n,Goto(s,loop)
exten => 2,1,Playback(youselect)
same => n,SayNumber(2)
same => n,Goto(s,loop)
exten => 3,1,Playback(youselect)
same => n,SayNumber(3)
same => n,Goto(s,loop)
exten => 4,1,Playback(youselect)
same => n,SayNumber(4)
same => n,Goto(s,loop)
exten => 5,1,Playback(youselect)
same => n,SayNumber(5)
same => n,Goto(s,loop)
exten => i,1,playback(invalid)
same => n,Goto(s,loop)
exten => t,1,Goto(i,1)