Asterisk:创建一个多级IVR示例

时间:2011-07-21 02:36:36

标签: asterisk ivr

我想为多级IVR创建一个示例。让我们说一个欢迎菜单,要求您输入您的员工。之后还有第二个菜单,您可以选择返回上一个菜单。知道怎么做吗?

这是一个不起作用的伪代码示例,因为我还不知道如何创建多级IVR。

[TestMenu]

exten => start,1,Answer()
     same => n,Log(NOTICE, call starts)
     same => n,Background(welcomeintro)  // welcome menu

     same => n,Background(welcomeoption)  // options that your have
     same => n,WaitExten(5)

exten => 0,1,Playback(digits/0) ; if enter 0, play back the welcome menu
 same => n,Goto(TestMenu,start,1)  // ??? is it ok ?  and suppose that I want to skip to Background(welcomeoption) part directly ?

// if 1 is enterred, lets ask for employeeid
exten => 1,1,Playback(digits/1) ; 
 same => n,Playback(askemployeeid)
 same => n,goto ????

exten => i,1,Playback(pbx-invalid)   ; invalid
    same => n,Goto(TestMenu,start,1)

exten => t,1,Playback(byebye) ; timeout
    same => n,Hangup()

[employeeid]
....

假设employeeid是1-8而9是回到上一个菜单。输入1-8后,它将播放音频文件并退出。

1 个答案:

答案 0 :(得分:2)

[TestMenu]

exten => 0,n,Verbose(1, "Inside test-menu")
exten => 0,n(TestMenu-start),NoOp()

exten => 0,n(welcomeIntro-skip-press5),Background(welcomeintro)   ;If user presses 5, he skips this.

exten => 0,n(welcomeIntro-skipped),NoOp()

exten => 0,n,Background(welcomeoption)
exten => 0,n,Set(USERCHOICE1=0)  ;This is the first choice that the user will enter.
exten => 0,n,Read(USERCHOICE1,,1,,1,10)    ;Read the documentation on Read function to know what this does.

exten => 0,n,Playback(enteredChoice)
exten => 0,n,SayDigits(${USERCHOICE1})
exten => 0,n,ExecIf($[${USERCHOICE1} = 1]?Goto(askEmpID,0,askEmpID-start))

exten => 5,1,Goto(TestMenu,0,welcomeIntro-skipped)
exten => i,1,Playback(pbx-invalid)   ; invalid
exten => t,1,Playback(byebye) ; timeout

[askEmpID]
....

suppose that the employeeid is 1-8
and 9 is for going back to the previous menu.

and when 1-8 is entered, it will play a audio file and quit.

这只是代码可能的样子的一小部分。您可以对此进行处理并根据您的要求进行定制。请注意,我还没有测试过它。

HTH。