freeswitch动态加载坐席

功能

通过freeswitch动态加载mysql数据库中配置的坐席,完成动态生成坐席功能

本人已经使用freeswitch开发出整体的核心产品,提供功能接口,通过接口即可实现呼叫中心业务功能,无需关心freeswitch开发。功能包括IVR动态导航、坐席动态添加、动态拨号计划、坐席登入、登出、置忙、空闲、通话、呼叫转移、呼叫保持、墙插、强拆、通话记录上传、弹屏上传等功能,只需要调用http接口即可实现呼叫中心业务,有意合作可邮箱联系mokeily99@126.com

原理

坐席的动态添加有两种方式,一种是通过mod_xml_curl,另一种是通过mod_lua

本次采用的是mod_lua模块。

mod_lua是通过lua.conf.xml加载lua脚本,lua脚本通过查询数据库组装成xml返回给lua.conf.xml从而完成坐席的动态加载。

注:mod_lua绑定目标有三个分别是directoryconfigurationdialplan。但是测试发现只能绑定一种,没有mod_xml_curl功能强大

步骤

1、加载mod_lua

freeswitch/conf/autoload_configs/modules.conf.xml<load module="mod_lua"/>的注释去掉

重启freeswitch或者load mod_lua

2、配置lua.conf.xml文件

进入freeswitch/conf/autoload_configs下编辑lua.conf.xml文件,如下

<param name="xml-handler-script" value="init_user_xml.lua"/>

<param name="xml-handler-bindings" value="directory"/>

为修改内容

<configuration name="lua.conf" description="LUA Configuration">
  <settings>

    <!--
    Specify local directories that will be searched for LUA modules
    These entries will be pre-pended to the LUA_CPATH environment variable
    -->
    <!-- <param name="module-directory" value="/usr/lib/lua/5.1/?.so"/> -->
    <!-- <param name="module-directory" value="/usr/local/lib/lua/5.1/?.so"/> -->

    <param name="script-directory" value="$${base_dir}/scripts/?.lua"/>
    <!--
    Specify local directories that will be searched for LUA scripts
    These entries will be pre-pended to the LUA_PATH environment variable
    -->
    <!-- <param name="script-directory" value="/usr/local/lua/?.lua"/> -->
    <!-- <param name="script-directory" value="$${script_dir}/?.lua"/> -->

    <!--<param name="xml-handler-script" value="/dp.lua"/>-->
    <!--<param name="xml-handler-bindings" value="dialplan"/>-->
        <param name="xml-handler-script" value="init_user_xml.lua"/>
        <param name="xml-handler-bindings" value="directory"/>

        <!--<param name="xml-handler-script" value="init_call_center_xml.lua"/>
    <param name="xml-handler-bindings" value="configuration"/>-->

    <!--
        The following options identifies a lua script that is launched
        at startup and may live forever in the background.
        You can define multiple lines, one for each script you
        need to run.
    -->
    <!--<param name="startup-script" value="startup_script_1.lua"/>-->
    <!--<param name="startup-script" value="startup_script_2.lua"/>-->

    <!--<hook event="CUSTOM" subclass="conference::maintenance" script="catch-event.lua"/>-->
  </settings>
</configuration> 

3、编写lua脚本

在script目录下编写init_user_xml.lua脚本,如下

freeswitch.consoleLog("NOTICE","lua take the users\r\n");
local req_domain = params:getHeader("domain")
local req_key    = params:getHeader("key")
local req_user   = params:getHeader("user")
local req_password = params:getHeader("pass")
local dbh = freeswitch.Dbh("MYSQLTP","root","xxxxxx");

if req_user ~= nil then
	freeswitch.consoleLog("NOTICE","lua take the users:"..req_user.."\r\n");
	
	freeswitch.consoleLog("NOTICE","req_user..."..req_user.."\r\n");
	local my_query = string.format("select seat_pwd from t_seat_info where seat_no='%s' limit 1", req_user)
	freeswitch.consoleLog("NOTICE","start connect DB...\r\n");
	assert(dbh:connected());
	--freeswitch.consoleLog("notice", "the query string is:"..my_query)
	dbh:query(my_query,function(row)
	   --freeswitch.consoleLog("NOTICE",string.format("%s\n",row.seat_pwd))
	   req_password=string.format("%s",row.seat_pwd)
	end);
	dbh:release();
	freeswitch.consoleLog("NOTICE","info:"..req_domain.."--"..req_key.."--"..req_user.."\n");

	--assert (req_domain and req_key and req_user,
	--"This example script only supports generating directory xml for a single user !\n")
	if req_domain ~= nil and req_key~=nil and req_user~=nil and req_password~=nil then
	   XML_STRING =
	   [[<?xml version="1.0" encoding="UTF-8" standalone="no"?>
	   <document type="freeswitch/xml">
		 <section name="directory">
		   <domain name="]]..req_domain..[[">
			 <params>
		   <param name="dial-string"
		   value="{presence_id=${dialed_user}@${dialed_domain}}${sofia_contact(${dialed_user}@${dialed_domain})}"/>
			 </params>
			 <groups>
		   <group name="default">
			 <users>
			   <user id="]] ..req_user..[[">
				 <params>
			   <param name="password" value="]]..req_password..[["/>
			   <param name="vm-password" value="]]..req_password..[["/>
				 </params>
				 <variables>
			   <variable name="toll_allow" value="domestic,international,local"/>
			   <variable name="accountcode" value="]] ..req_user..[["/>
			   <variable name="user_context" value="default"/>
			   <variable name="directory-visible" value="true"/>
			   <variable name="directory-exten-visible" value="true"/>
			   <variable name="limit_max" value="15"/>
			   <variable name="effective_caller_id_name" value="Extension ]] ..req_user..[["/>
			   <variable name="effective_caller_id_number" value="]] ..req_user..[["/>
			   <variable name="outbound_caller_id_name" value="${outbound_caller_name}"/>
			   <variable name="outbound_caller_id_number" value="${outbound_caller_id}"/>
			   <variable name="callgroup" value="techsupport"/>
				 </variables>
			   </user>
			 </users>
		   </group>
			 </groups>
		   </domain>
		 </section>
	   </document>]]
	else
	   XML_STRING =
	   [[<?xml version="1.0" encoding="UTF-8" standalone="no"?>
	   <document type="freeswitch/xml">
		 <section name="directory">
		 </section>
	   </document>]]
	end
end
-- comment the following line for production:
--freeswitch.consoleLog("notice", "Debug from init_user_xml.lua, generated XML:\n" .. XML_STRING .. "\n");

注:脚本中local dbh = freeswitch.Dbh("MYSQLTP","root","xxxxxx");

是连接数据库,root和xxxxxx是mysql账号密码,MYSQLTP是数据源。需要在系统中添加数据源。参照Freeswitch替换sqlLit改为mysql,同时记录通话话单_freeswitch mysql_十年一梦惊觉醒的博客-CSDN博客2配置mysqlDSN目标数据库需要创建坐席表,以及包含坐席号和密码字段。

5、完成以上步骤后建议重启freeswitch,然后用eyebeam登录表中配置的坐席即可

如有问题或合作请邮箱咨询mokeily99@126.com

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

十年一梦惊觉醒

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值