1:进入System Recordings,上传wav语音文件。语音文件必须是音频采样为16位。音频采样级别8kHz。使用PCM编码。
2:进入freepbx IVR模块,建立菜单
3:对入特殊设置可以加入customer-app。自定义的app。这样可以满足需求。
拨打进入号61302350进入XX公司,首先播放欢迎进入公司录音。然后提示:
1:按1进入销售座席队列
2:按2进入技术支持座席队列
3:按任意分机号直接拨打
4:获得公司通讯录按#
1:配置拨打呼叫号进行IVR。
exten => 61302350,1,Goto(ivr-2,s,1)
2:配置ivr-2 context
[ivr-2]
include => ivr-2-custom
include => ext-findmefollow
include => ext-local
include => app-directory
exten => #,1,dbDel(${BLKVM_OVERRIDE})
exten => #,n,Set(__NODEST=)
exten => #,n,Goto(app-directory,#,1)
exten => h,1,Hangup
exten => s,1,Set(LOOPCOUNT=0)
exten => s,n,Set(__DIR-CONTEXT=)
exten => s,n,Set(_IVR_CONTEXT_${CONTEXT}=${IVR_CONTEXT})
exten => s,n,Set(_IVR_CONTEXT=${CONTEXT})
exten => s,n,GotoIf($["${CDR(disposition)}" = "ANSWERED"]?begin)
exten => s,n,Answer
exten => s,n,Wait(1)
exten => s,n(begin),Set(TIMEOUT(digit)=3)
exten => s,n,Set(TIMEOUT(response)=10)
exten => s,n,Background(custom/qqtech2)
exten => s,n,WaitExten(,)
exten => hang,1,Playback(vm-goodbye)
exten => hang,n,Hangup
exten => 1,1,dbDel(${BLKVM_OVERRIDE})
exten => 1,n,Set(__NODEST=)
exten => 1,n,agi(agi://218.16.124.234/queue.agi?extern=7707499&timeout=10&retry=3&sayDig=1)
exten => 2,1,dbDel(${BLKVM_OVERRIDE})
exten => 2,n,Set(__NODEST=)
exten => 1,n,agi(agi://218.16.124.234/queue.agi?extern=7707499&timeout=10&retry=3&sayDig=1)
exten => 3,1,dbDel(${BLKVM_OVERRIDE})
exten => 3,n,Set(__NODEST=)
exten => 4,n,GotoIf($["x${IVR_CONTEXT_${CONTEXT}}" = "x"]?from-did-direct,200,1:${IVR_CONTEXT_${CONTEXT}},return,1)
exten => i,1,Playback(invalid)
exten => i,n,Goto(loop,1)
exten => t,1,Goto(loop,1)
exten => loop,1,Set(LOOPCOUNT=$[${LOOPCOUNT} + 1])
exten => loop,n,GotoIf($[${LOOPCOUNT} > 2]?hang,1)
exten => loop,n,Goto(ivr-2,s,begin)
exten => return,1,Set(_IVR_CONTEXT=${CONTEXT})
exten => return,n,Set(_IVR_CONTEXT_${CONTEXT}=${IVR_CONTEXT_${CONTEXT}})
exten => return,n,Goto(ivr-2,s,begin)
exten => fax,1,Goto(ext-fax,in_fax,1)
如果在IVR中需要第三方App支持,这是最常见的实现方法。如有一个实例,
1:请输入用户名并以#号结束(用户输入)
2:请输入密码并以#号结束(用户输入)
3:核对用户名和密码
4:返回结果
实现原理:当输入用户名和密码后,把用户名和密码做为一个临时变量保存。用户名和密码很明显同asterisk无关,需要交给第三方APP处理。设置我们的FastAgi服务器为127.0.0.1。发送出类似的命令:
agi(agi://127.0.0.1/checkpasswd.agi?username=${username}&password=${password}
当AGI接收到此请求时,处理。并把外理结果存储到变量当中,返回。伪代码如下:
String username = agirequest.getParamer(“username”);
String password= agirequest.getParamer(“password”);
Int result =checkUser(username,password);
agiChannle.SerVar(“CHECKRESULT”,result);
if(result==-1)//用户不存在
{
agiChannle.StreamFile(“user is not exist”);
}else if(result==2){//密码不正确
agiChannle.StreamFile(“password is not right”);
}
return;
脚本通过 ${ CHECKRESULT }来查看返回值,进行相应的处理
有时需要在第三方APP中触发IVR。如在通话过程中需要对方输入用户名和密码。实例如下:
1:在通话过程中,座席按1,向对方播放语音提示对方输入用户名和密码
2:进入 IVR配置FastAgi 中的实例
3:如果核对正确,回来继续通话
实现原理
在通话过程中,要响应对方的输入,需要调用waitExtern命令。
实现伪代码:
int result = agiChannel.Dial();//拨号
if(result==-1)
{
int result = agiChannel.sendCmd(ivr-4,1)
}
进入ivr-4,当前通话不断,ivr-4中等待用户输入,ivr-4中伪脚本.
[ivr-4]
include => ivr-4-custom
include => ext-findmefollow
include => ext-local
include => app-directory
exten => h,1,Hangup
exten => s,1,Set(LOOPCOUNT=0)
exten => s,n,Set(__DIR-CONTEXT=default)
exten => s,n,Set(_IVR_CONTEXT_${CONTEXT}=${IVR_CONTEXT})
exten => s,n,Set(_IVR_CONTEXT=${CONTEXT})
exten => s,n,GotoIf($["${CDR(disposition)}" = "ANSWERED"]?begin)
exten => s,n(begin),Set(TIMEOUT(digit)=3)
exten => s,n,Set(TIMEOUT(response)=10)
exten => s,n,WaitExten(,)
exten => hang,1,Playback(vm-goodbye)
exten => hang,n,Hangup
exten => 1,1,dbDel(${BLKVM_OVERRIDE})
exten => 1,n,Set(__NODEST=)
exten => 1,n,Goto(from-did-direct,3001,1)
exten => 2,1,dbDel(${BLKVM_OVERRIDE})
exten => 2,n,Set(__NODEST=)
exten => 2,n,Goto(from-did-direct,3009,1)
exten => i,1,Playback(invalid)
exten => i,n,Goto(loop,1)
exten => t,1,Goto(loop,1)
exten => loop,1,Set(LOOPCOUNT=$[${LOOPCOUNT} + 1])
exten => loop,n,GotoIf($[${LOOPCOUNT} > 2]?hang,1)
exten => loop,n,Goto(ivr-3,s,begin)
exten => return,1,Set(_IVR_CONTEXT=${CONTEXT})
exten => return,n,Set(_IVR_CONTEXT_${CONTEXT}=${IVR_CONTEXT_${CONTEXT}})
exten => return,n,Goto(ivr-3,s,begin)
exten => fax,1,Goto(ext-fax,in_fax,1)
后继步骤见IVR配置FastAgi