一、背景介绍:

  虽然使用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路客服的服务。

ADC自动转接功能Lua实现的更多相关文章

  1. 基于JQuery实现的文本框自动填充功能

    1. 实现的方法 /* * js实现的文本框的自动完成功能 */ function doAutoComplete(textid,dataid,url){ $("#" + texti ...

  2. redis技巧--自动完成功能实现

    自动完成功能一般都伴随搜索框出现,就是用户在输入时帮助其自动补全. 比如对成语进行补全,现有如下成语:一心一意,一心二用,一帆风顺. 两种实现方式: 实现方式一: 为每个成语的每个前缀都使用一个集合类 ...

  3. eclipse自动提示功能没了的解决办法(转载)

    eclipse自动提示功能没了的解决办法 标签: eclipse联想 2012-08-09 14:32 24687人阅读 评论(7) 收藏 举报  分类: Android(38)  版权声明:本文为博 ...

  4. xcode6 beta 中智能提示(自动完成)功能有时不显示的问题

    xcode6 beta 中智能提示(自动完成)功能有时不显示的问题      周银辉 xcode6 beta 中智能提示(自动完成)功能有时不显示,这让人很郁闷啊,网上老外的视频中看人家用的好好的. ...

  5. 修改eclipse的自动完成功能

    修改eclipse的自动完成功能   周银辉 用eclipse时还是比较习惯Visual Studio那样的敲一个字母就弹出自动完成框,而不是总要等到敲.号,其实可以设置的: 在preferences ...

  6. 禁用datagridview中的自动排序功能

    把datagridview中的自动排序功能禁用自己收集的两种方法,看看吧①DataGridView中的Columns属性里面可以设置.进入"EditColumns"窗口后,在相应的 ...

  7. 解决 PhpStorm 对 用单例模式实例化PHP类时,代码自动提示功能失效 的问题

    大部分PHP框架中,为了防止一个类被重复实例化,往往采用“单例模式”实例化类.我们的项目框架是这样做的: 先写好一个基类 /framework/Base.class.php,内容如下: <?ph ...

  8. 在MyEclipse显示struts2源码和doc文档及自动完成功能

    分类: struts2 2010-01-07 16:34 1498人阅读 评论(1) 收藏 举报 myeclipsestruts文档xmlfileurl 在MyEclipse显示struts2源码和d ...

  9. Eclipse配置PHP及自动提示功能

    Eclipse是一个开发工具,具有强大的插件功能,虽然用于Java理所当然,但为PHP所用,也为尝不可.虽然我一直用的是notepad,但发现开发工具也可以省去一些不必要的记忆. 言归正传,下面就来实 ...

随机推荐

  1. 2018 省选 T1 一双木棋

    题目描述 菲菲和牛牛在一块n 行m 列的棋盘上下棋,菲菲执黑棋先手,牛牛执白棋后手. 棋局开始时,棋盘上没有任何棋子,两人轮流在格子上落子,直到填满棋盘时结束. 落子的规则是:一个格子可以落子当且仅当 ...

  2. C# 类&结构体&枚举

    类: class Lei  //要和static void Main(string[] args)平级: { public int lei_int;  //public是关键字,代表访问权限,这里是公 ...

  3. 【CH5302】金字塔 区间DP

    题目大意:给定一棵树,树上点有标记,给定一棵树的\(dfs\)序标记序列,求有多少种可能的子树形态.(子树之间有序) 这是一道区间计数类DP,涉及到树的\(dfs\)序. 这道题区间的划分点 \(k\ ...

  4. property(四十)

    一个静态属性property本质就是实现了get,set,delete三种方法 用法: class Foo: @property def AAA(self): print('get的时候运行我啊') ...

  5. react缓存问题

    问题一: 问题描述: 我们公司自己的react项目,先打包部署v1.1版本,一切正常. v1.2版本做了很多页面和功能的修改和新增,但是打包部署之后,发现有些界面还是保持了v1.1的状态,比如有些新增 ...

  6. array扩展运算符

    扩展运算符(spread)是三个点(...).它好比 rest 参数的逆运算,将一个数组转为用逗号分隔的参数序列. console.log(...[1, 2, 3]) // 1 2 3 console ...

  7. 洛谷 P3951 小凯的疑惑(数学)

    传送门:Problem P3951 https://www.cnblogs.com/violet-acmer/p/9827010.html 参考资料: [1]:http://m.blog.sina.c ...

  8. can't open file 'manage.py': [Errno 2] No such file or directory

    python Django创建数据库时can't open file 'manage.py': [Errno 2] No such file or directory 参考https://blog.c ...

  9. Kubernetes Pv & Pvc

    Kubernetes PV & pvc 介绍 PersistentVolume(pv)和PersistentVolumeClaim(pvc)是k8s提供的两种API资源,用于抽象存储细节.管理 ...

  10. elasticsearch 动态模板设置

    自定义动态映射 如果你想在运行时增加新的字段,你可能会启用动态映射.然而,有时候,动态映射 规则 可能不太智能.幸运的是,我们可以通过设置去自定义这些规则,以便更好的适用于你的数据. 日期检测 当 E ...