Featured image of post opensips call_center模块

opensips call_center模块

背景

call_center是一个带有呼入队列和坐席的呼叫中心,实现了呼入排队,坐席分配,坐席管理,坐席CDR, 依赖b2b_logicdatabase。官方文档地址:call_center

本次测试的opensips版本为:

version: opensips 3.5.5 (x86_64/linux)

目前没调通, 只是记录一下测试情况。

参数解析

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# 数据库地址,cc_flows, cc_agents, cc_calls表
modparam("call_center", "db_url", "DB_URL")
# 数据库地址,cc_cdrs表
modparam("call_center", "acc_db_url", "DB_URL")
# 运行时的库地址,只有cc_calls表
modparam("call_center", "rt_db_url", "DB_URL")
# 坐席呼叫完成后,下一次接收呼叫的等待时间,默认: 30s
modparam("call_center", "wrapup_time", 45)
# 将呼叫发送给媒体进行等待播放时,用于报告等待队列中的SIPURL的参数名称.
modparam("call_center", "queue_pos_param", "cc_pos")
# 当没有可用的坐席时,是否拒绝呼叫,默认: 1
modparam("call_center", "reject_on_no_agents", 0)
# 分发坐席的策略, balancing: 轮询分配 ;full-load:当有坐席接通后,后面的呼叫不会分配给其他坐席
modparam("call_center", "chat_dispatch_policy", "balancing")
# 内部电话是否也进行分机分配,默认: 1
modparam("call_center", "internal_call_dispatching", 0)
# 坐席表,默认:"cc_agents"
modparam("call_center", "cc_agents_table", "my_agents")
# 流程表,默认: "cc_flows"
modparam("call_center", "cc_flows_table", "queues")
# $b2b_logic.ctx变量名
modparam("call_center", "b2b_logic_ctx_param", "b2b_callid")

重要函数

cc_handle_call( flowID [,param])

必须用在INVITE请求中, 返回值:

  • -1: 不能获取flowID参数
  • -2: 不能解析From URI
  • -3: flowID在数据库中没找到
  • -4: 没有坐席在该flow中
  • -5: 内部错误

cc_agent_login(agentID, state)

设置坐席的状态, state:0,下线;其他:上线

实战

配置示例

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
loadmodule "event_route.so"
loadmodule "uac_auth.so"
loadmodule "b2b_entities.so"
loadmodule "b2b_logic.so"
loadmodule "call_center.so

modparam("b2b_logic", "contact_user", 1)
modparam("b2b_logic", "server_address", "sip:$fU@$socket_in(ip):$socket_in(port)")
modparam("b2b_logic", "db_mode", 1)
modparam("b2b_logic", "b2bl_th_init_timeout", 60)

modparam("call_center", "db_url", "mysql://opensips:opensipsrw@172.16.4.111/opensips_3_5")
modparam("call_center", "wrapup_time", 45)
modparam("call_center", "queue_pos_param", "cc_pos")

route {
    ...
    if(is_method("INVITE") && !has_totag()) {
        xlog("L_DBG","[$cfg_line][$ci]---call-center-new--rm|$rs|$tu|$socket_in(port)|$var(contact)\n");
        if (!cc_handle_call("tech_support")) {
                send_reply(403,"Cannot handle call");
                exit;
        }
        exit;
    }
    ...
}

event_route[E_CALLCENTER_AGENT_REPORT]{
        xlog("L_INFO", "$param(1), $param(2)\n");      
}

数据表cc_flows插入数据:

1
insert into opensips_3_5.cc_flows('flowid','skill','message_welcome','message_queue')value('tech_support','test','sip:9999@172.16.4.114:5060','sip:172.16.4.113:5050');

数据表cc_agent插入数据:

1
insert into opensips_3_5.cc_agents('agentid','location','skills')values('1008','sip:1008@172.16.4.114:5060','test');

测试

理想的逻辑应该是软电话1005呼叫1008, 播放等待音,再拨打1008号码. 目前只到了播放等待音,不能转坐席.

  1. 手动让坐席上线

opensips-cli -x mi cc_agent_login 1008 1

  1. 软电话1005呼叫1008

sip

可以看到call_center使用了b2b_logic生成新的call-id:

invite

新的请求SIP URL的地址是cc_flows里的message_welcome字段, 172.16.4.114:5060freeswitch,我配了个播放音的dialplain/public.xml

1
2
3
4
5
6
7
<extension name="play_9999">
  <condition field="destination_number" expression="^9999$">
    <action application="answer"/>
    <action application="sleep" data="1000"/>
    <action application="playback" data="/usr/local/freeswitch/share/freeswitch/sounds/en/us/callie/ivr/48000/ivr-welcome_to_freeswitch.wav"/>
  </condition>
</extension>

报错日志:

1
2
3
4
5
6
7
8
Jul  1 15:20:17 [839] DBG:[245][5ecb0e8751ce43bebbd0629278e025b1]---call-center-new--rm|<null>|sip:1008@172.16.4.111|5261|<null>
Jul  1 15:20:21 [838] WARNING:b2b_logic:b2b_get_local_contact: Failed to print format string from 'server_address'
Jul  1 15:20:21 [838] ERROR:b2b_logic:b2b_get_local_contact: No current SIP message, failed to build Contact from send socket
Jul  1 15:20:21 [838] ERROR:b2b_logic:b2bl_new_client: Failed to build Contact
Jul  1 15:20:21 [838] ERROR:b2b_logic:bridging_new_client: Failed to generate new client
Jul  1 15:20:21 [838] ERROR:b2b_logic:b2bl_api_bridge: Failed to start bridging with new entity
Jul  1 15:20:21 [838] ERROR:call_center:set_call_leg: bridging failed
Jul  1 15:20:21 [838] ERROR:call_center:b2bl_callback_customer: failed to set new destination for call

目前没有找到正确使用call_centeropensips.cfg配置.

本博客已稳定运行
发表了47篇文章 · 总计81.34k字
本站总访问量 次 · 您是本站第 位访问者
粤ICP备2025368587号-1| 使用 Hugo 构建
主题 StackJimmy 设计