下面为简单的一个电话查询系统,功能很小,练练手,功能基本OK,但不够尽善尽美,只能满足基本的功能。
..................................................................................................................................................................................................
IVR:欢迎致电学员成绩电话查询系统,学员成绩查询请按1,人工查询请按2,学员管理请按3(管理员使用)。。。按其它键提示错误或重新回到什么什么按1或2
按键1:请输入学员编号,如果输入没有该编号,提示不存在或再提示回到请输入学员拨号,输入正确后提示“您的成绩为多少多少分”然后挂机.(当然这里还很多什么什么重新查询啊。什么的。。原理一样.我就没继续做了)
按键2: 转某个分机,或者队列。。。
按键3:(先提示输入管理员密码)修改学员成绩请按1,删除错误学员成绩请按2(添加学员编号就没做了。)
按1:请输入要修改学员的编号(与数据库查询,同样输入不存在的编号,提示错误,或重新提示),然后提示请输入要修改次学员的成绩,输入后提示修改成功,并重新读取数据,提示修改后的成绩为多少多少
按2: 请输入要删除学员成绩的编号,(与数据库查询,同样输入不存在的编号,提示错误,或重新提示),输入正确后,提示删除成功。。什么什么
..................................................................................................................................................................................................
数据库结构:
s_uid s_name s_relts
(学员编号) (学员姓名) (学员成绩)
1000 浩子 888
1001 voip 666
........ ........ .......
..................................................................................................................................................................................................
下面为整个实现功能的Dialplan 代码,有点乱,程序当然还可以优化,先这么整吧。。
- [code]
- [globals] ;定义全局变量
- ;................................................mysql
- DBCurrentHost=localhost
- DBuser=root
- DBpass=888888
- DBname=asterisk_test
- ;........................................
- [from-internal] ;欢迎提示,xxxxxx按1或按2
- exten => _x.,1,Answer(${EXTEN})
- exten => _x.,n,NoOP(${EXTEN})
- exten => _x.,n(read1),Read(a,stu/welcome,1,,2,5)
- exten => _x.,n(lan1),Gotoif($["${a}"="1"]?menu1,${EXTEN},1:lan2)
- exten => _x.,n(lan2),Gotoif($["${a}"="2"]?menu2,${EXTEN},1:lan0)
- exten => _x.,n(lan0),Gotoif($["${a}"="0"]?menu0,${EXTEN},1:exen0,${EXTEN},1)
- [exen0] ;欢迎提示按其它键的报错提示,然后重新回到welcome
- exten => _x.,1,Answer(${EXTEN})
- exten => _x.,n,NoOP(${EXTEN})
- exten => _x.,n,wait(1)
- exten => _x.,n,Playback(stu/exen0)
- exten => _x.,n,Gotoif($["1"="1"]?from-internal,${EXTEN},read1)
- [menu1] ;按1键后的操作,输入学员拨号,进行查询
- exten => _x.,1,Answer(${EXTEN})
- exten => _x.,n,NoOP(${EXTEN})
- exten => _x.,n,wait(1)
- exten => _x.,n(read1),Read(bhao,stu/stubhao,20,,2,5)
- exten => _x.,n,Set(ID=${bhao})
- exten => _x.,n,MySql(connect connid ${DBCurrentHost} ${DBuser} ${DBpass} ${DBname})
- exten => _x.,n,MySql(query resultidr ${connid} select s_uid/,s_relts from stu where s_uid=${ID})
- exten => _x.,n,MySql(Fetch foundrow ${resultidr} s_uid s_relts)
- exten => _x.,n,MySql(clear ${resultidr})
- exten => _x.,n,MySql(disconnect ${connid})
- exten => _x.,n,Gotoif($["${ID}"="${s_uid}"]?jieg:read1)
- exten => _x.,n(jieg),playback(stu/jieg)
- ;exten => _x.,n,Dial(SIP/${s_relts})
- exten => _x.,n,SayNumber(${s_relts})
- exten => _x.,n,Playback(stu/fen)
- exten => _x.,n,Hangup()
- [menu2] ;人工查询后的操作
- exten => _x.,1,Answer(${EXTEN})
- exten => _x.,n,NoOP(${EXTEN})
- exten => _x.,n,Dial(SIP/8111,10)
- exten => _x.,n,playback(stu/mang)
- exten => _x.,n,Hangup()
- [menu0] ;按0键后的操作,管理员使用
- exten => _x.,1,Answer(${EXTEN})
- exten => _x.,n,NoOP(${EXTEN})
- exten => _x.,n,MySql(connect connid ${DBCurrentHost} ${DBuser} ${DBpass} ${DBname})
- exten => _x.,n,MySql(query result ${connid} select s_pass from ampuser)
- exten => _x.,n,MySql(Fetch foundrow ${result} s_pass)
- exten => _x.,n,MySql(clear ${result})
- exten => _x.,n,MySql(disconnect ${connid})
- exten => _x.,n,Authenticate(${s_pass})
- exten => _x.,n(read1),Read(stubhao,stu/stucjivr,1,,2,5)
- exten => _x.,n(lan1),Gotoif($["${stubhao}"="1"]?update,${EXTEN},1:lan2)
- exten => _x.,n(lan2),Gotoif($["${stubhao}"="2"]?delete,${EXTEN},1:read1)
- [update] ;修改学员成绩拨号
- exten => _x.,1,Answer(${EXTEN})
- exten => _x.,n,NoOP(${EXTEN})
- exten => _x.,n(read1),Read(update,stu/update_stu,10,,2,5)
- exten => _x.,n,MySql(connect connid ${DBCurrentHost} ${DBuser} ${DBpass} ${DBname})
- exten => _x.,n,MySql(query resultidr ${connid} select s_uid/,s_relts from stu where s_uid=${update})
- exten => _x.,n,MySql(Fetch foundrow ${resultidr} s_uid s_relts)
- exten => _x.,n,MySql(clear ${resultidr})
- exten => _x.,n,MySql(disconnect ${connid})
- exten => _x.,n,Gotoif($["${update}"="${s_uid}"]?lanup:read1)
- exten => _x.,n(lanup),Read(cj,stu/xhao1,10,,2,5)
- exten => _x.,n,MySql(connect connid ${DBCurrentHost} ${DBuser} ${DBpass} ${DBname})
- exten => _x.,n,MySql(query resultidr ${connid} update stu set s_relts ='${cj}' where s_uid=${s_uid})
- exten => _x.,n,MySql(disconnect ${connid})
- exten => _x.,n,MySql(connect connid ${DBCurrentHost} ${DBuser} ${DBpass} ${DBname})
- exten => _x.,n,MySql(query resultidr ${connid} select s_uid/,s_relts from stu where s_uid=${update})
- exten => _x.,n,MySql(Fetch foundrow ${resultidr} s_uid s_relts)
- exten => _x.,n,MySql(clear ${resultidr})
- exten => _x.,n,MySql(disconnect ${connid})
- exten => _x.,n,playback(stu/update_cj)
- exten => _x.,n,SayNumber(${s_relts})
- exten => _x.,n,Playback(stu/fen)
- exten => _x.,n,Hangup()
- [delete] ;删除错误的学员信息操作
- exten => _x.,1,Answer(${EXTEN})
- exten => _x.,n,NoOP(${EXTEN})
- exten => _x.,n(delete1),Read(deletebhao,stu/delete_bhao,10,,2,5)
- exten => _x.,n,MySql(connect connid ${DBCurrentHost} ${DBuser} ${DBpass} ${DBname})
- exten => _x.,n,MySql(query resultidr ${connid} select s_uid/,s_relts from stu where s_uid=${deletebhao})
- exten => _x.,n,MySql(Fetch foundrow ${resultidr} s_uid s_relts)
- exten => _x.,n,MySql(clear ${resultidr})
- exten => _x.,n,MySql(disconnect ${connid})
- exten => _x.,n,Gotoif($["${deletebhao}"="${s_uid}"]?delete:delete1)
- exten => _x.,n(delete),MySql(connect connid ${DBCurrentHost} ${DBuser} ${DBpass} ${DBname})
- exten => _x.,n,MySql(query resultidr ${connid} delete from stu where s_uid=${deletebhao})
- exten => _x.,n,MySql(disconnect ${connid})
- exten => _x.,n,Playback(stu/delbhao)
- exten => _x.,n,SayAlpha(${deletebhao})
- exten => _x.,n,Playback(stu/deletejg)
- exten => _x.,n,Hangup()
- ; 添加就木做了
|