一、背景介绍:
虽然使用Mod_fifo和mod_callcenter可以做呼叫中心的应用,但在实现应用中,这两个模块很难客制化需求,再此我用Lua实现了5路客服(1000-1004),一个呼叫中心号码:9958 的ADC实施方案,谨在此记录。
二、流程图:
三、具体设定:
1 . /usr/local/freeswitch/conf/autoload_confilgs/modules.conf.xml 中加在 mod_lua模块,默认是加载的;
2. 在/usr/local/freeswitch/conf/var.xml 中添加5个全局变量,标识客服号码通话状态,内容如下:
<!-- yjCallCenter Sets: 0 allow the call, 1 busy -->
<X-PRE-PROCESS cmd="set" data="yj1000=0"/>
<X-PRE-PROCESS cmd="set" data="yj1001=0"/>
<X-PRE-PROCESS cmd="set" data="yj1002=0"/>
<X-PRE-PROCESS cmd="set" data="yj1003=0"/>
<X-PRE-PROCESS cmd="set" data="yj1004=0"/>
3. 在/usr/local/freeswitch/conf/dialplan/default 目录下添加 9958_callcenter.xml ,内容如下:
<extension name="yj_callcenter">
<condition field="destination_number" expression="^(9958)$">
<action application="lua" data="yjcall.lua"/>
</condition>
</extension>
4. 在/usr/local/freeswitch/scripts 目录下添加yjcall.lua,内容如下:
print("\n*******logo_fox's CallCenter******\n")
api=freeswitch.API();
local yj1000= freeswitch.getGlobalVariable("yj1000");
local yj1001= freeswitch.getGlobalVariable("yj1001");
local yj1002= freeswitch.getGlobalVariable("yj1002");
local yj1003= freeswitch.getGlobalVariable("yj1003");
local yj1004= freeswitch.getGlobalVariable("yj1004");
function yjCheck(command,lineNum,info)
local yjdata=api:executeString(command);
local i1,j1=string.find(yjdata,"100"..lineNum);
if(info=="LineStatusCheck") then
if(i1~=nil and i1>0) then
api:executeString("global_setvar yj100"..lineNum.."=1");
else
api:executeString("global_setvar yj100"..lineNum.."=0");
end
end
if(info=="RegistionCheck") then
if(i1~=nil and i1>0) then
return 1;
else
return 0;
end
end
end
local L1000=yjCheck("sofia status profile internal reg",0,"RegistionCheck");
local L1001=yjCheck("sofia status profile internal reg",1,"RegistionCheck");
local L1002=yjCheck("sofia status profile internal reg",2,"RegistionCheck");
local L1003=yjCheck("sofia status profile internal reg",3,"RegistionCheck");
local L1004=yjCheck("sofia status profile internal reg",4,"RegistionCheck");
for i=0,4,1 do
yjCheck("show calls",i,"LineStatusCheck");
end
yj1000= freeswitch.getGlobalVariable("yj1000");
yj1001= freeswitch.getGlobalVariable("yj1001");
yj1002= freeswitch.getGlobalVariable("yj1002");
yj1003= freeswitch.getGlobalVariable("yj1003");
yj1004= freeswitch.getGlobalVariable("yj1004");
if(yj1000=="0" and L1000==1) then
print("------Customer 1000 is at your service------");
api:executeString("global_setvar yj1000=1");
session:transfer("1000","xml","default");
return;
end
if(yj1001=="0" and L1001==1) then
print("------Customer 1001 is at your service------");
api:executeString("global_setvar yj1001=1");
session:transfer("1001","xml","default");
return;
end
if(yj1002=="0" and L1002==1) then
print("------Customer 1002 is at your service------");
api:executeString("global_setvar yj1002=1");
session:transfer("1002","xml","default");
return;
end
if(yj1003=="0" and L1003==1) then
print("------Customer 1003 is at your service------");
api:executeString("global_setvar yj1003=1");
session:transfer("1003","xml","default");
return;
end
if(yj1004=="0" and L1004==1) then
print("------Customer 1004 is at your service------");
api:executeString("global_setvar yj1004=1");
session:transfer("1004","xml","default");
return;
end
print("---------No available line, please wait dial!!----------");
session:hangup();
到此,ADC功能已经设定完毕,呼叫9958即可实现5路客服的服务。