Administrator
发布于 2026-10-30 / 2 阅读
0
0

Connect FreeSWITCH extensions to a call-center queue | Practical 02

English
中文

Extensions 7101 and 7102 can register and call each other. This installment adds a queue: a third registered test extension dials 7190, waits with music, and reaches an available agent. Reserve 7101 and 7102 for answering queue calls.

The example targets a single FreeSWITCH test server on a LAN, checked against the v1.10.12 vanilla template and current documentation. It has not been deployed in your environment. CONF means the result of eval {conf_dir}; eval {domain} identifies the actual user domain. XML preprocessing expands $${domain}.

Identify the objects

A SIP user authenticates a phone. An agent is the queue system's named destination. A queue holds and distributes callers. A tier assigns an agent to a queue. Here agent7101 and agent7102 are arbitrary agent identifiers; contact supplies the actual dial target. The @default suffix in training@default is part of a queue name, not an automatic association with a SIP domain or dialplan context.

Prepare the module and registrations

In fs_cli inspect:

version
module_exists mod_callcenter
sofia status profile internal reg

Both phones should be registered and directly reachable. Replace internal if your Profile differs. If the module is absent, ensure its binary is installed and enable this line inside modules in autoload_configs/modules.conf.xml,My Docker image already includes this module:

<!-- Load the call-center module on startup -->
<load module="mod_callcenter"/>

Add the test configuration

Back up CONF/autoload_configs/callcenter.conf.xml. The following complete minimal file suits a dedicated test instance. On an existing system merge the new queue, agents and tiers into their corresponding elements and preserve existing settings and services.

<configuration name="callcenter.conf" description="Training queue">
  <settings/>
  <queues>
    <!-- 名字在dialplan和tier中保持一致 -->
    <queue name="training@default">
      <!-- 优先选择空闲时间较长的座席 -->
      <param name="strategy" value="longest-idle-agent"/>
      <!-- 使用已有的全局等待音乐源 -->
      <param name="moh-sound" value="$${hold_music}"/>
      <!-- 按进入本系统的时间累计基础分数 -->
      <param name="time-base-score" value="system"/>
      <!-- 本例最多等待60秒,按实际流程调整 -->
      <param name="max-wait-time" value="60"/>
      <!-- 本例暂不启用分层等待规则 -->
      <param name="tier-rules-apply" value="false"/>
    </queue>
  </queues>
  <agents>
    <!-- callback表示需要派单时主动呼叫contact -->
    <agent name="agent7101" type="callback"
      contact="[leg_timeout=15]user/7101@$${domain}"
      status="Available" max-no-answer="3" wrap-up-time="10"
      reject-delay-time="10" busy-delay-time="30"/>
    <!-- 7102使用独立agent名称和分机目标 -->
    <agent name="agent7102" type="callback"
      contact="[leg_timeout=15]user/7102@$${domain}"
      status="Available" max-no-answer="3" wrap-up-time="10"
      reject-delay-time="10" busy-delay-time="30"/>
  </agents>
  <tiers>
    <!-- 同一层的两个座席都属于测试队列 -->
    <tier agent="agent7101" queue="training@default" level="1" position="1"/>
    <tier agent="agent7102" queue="training@default" level="1" position="2"/>
  </tiers>
</configuration>

longest-idle-agent prefers the agent idle longest; position does not guarantee that 7101 always rings first. moh-sound uses an existing working hold-music source. The example's max-wait-time is 60 seconds, after which the application can return to subsequent routing. time-base-score=system scores time from entry into the system; queue uses time in the queue. This matters for callers already waiting or transferred between queues.

callback originates a call to contact when an agent is selected. user/7101@domain resolves the registered user. leg_timeout=15 is a per-agent answer wait in seconds. Available makes the agent eligible; it is independent of SIP registration. On Break pauses offers and Logged Out signs the agent out. State tracks the dispatch lifecycle, such as Waiting or Receiving, and is normally managed by the module.

max-no-answer=3 controls accumulated unanswered offers, not three guaranteed attempts for every caller. wrap-up-time=10 reserves ten seconds after a call. reject-delay-time=10 and busy-delay-time=30 delay another offer after rejection or busy respectively. Check a wrong contact before shortening these delays.

Tiers provide level and position within the queue. Both agents use level 1, with tier-rules-apply=false, so this is not a demonstration of staged escalation. An incorrect queue or agent name breaks the association even when status says Available.

Route 7190 into the queue

Confirm that dialplan/default.xml includes default/*.xml in the default context, and the test caller enters that context. Check that 7190 is unused, then create CONF/dialplan/default/02_training_queue.xml:

<include>
  <extension name="training-queue-7190">
    <!-- 只匹配测试号码7190 -->
    <condition field="destination_number" expression="^7190$">
      <!-- 先应答来电,再播放排队音乐 -->
      <action application="answer"/>
      <!-- 名称与上面的queue完全相同 -->
      <action application="callcenter" data="training@default"/>
      <!-- 没有在队列完成通话而返回时,结束本例流程 -->
      <action application="hangup"/>
    </condition>
  </extension>
</include>

answer accepts the caller before queueing; a carrier may start charging at that point. Use internal test calls here. The final hangup ends this simple flow when callcenter returns without completing the conversation. Later routing can play a prepared prompt, transfer to another queue or reach voicemail. Distinct exit handling can use actual channel information such as cc_cause.

Load and inspect runtime objects

For a first-time setup with the module unloaded, save the files, run reloadxml and then load mod_callcenter. Check adjacent logs if loading fails. The example leaves odbc-dsn unset and uses the module's default local state database; no new PostgreSQL database is needed.

For a running module, rereading XML also requires synchronizing the specific objects:

reloadxml
callcenter_config queue load training@default
callcenter_config agent reload agent7101
callcenter_config agent reload agent7102
callcenter_config tier reload training@default agent7101
callcenter_config tier reload training@default agent7102
callcenter_config queue list
callcenter_config queue list agents training@default
callcenter_config queue list tiers training@default

queue load is for a new queue. For an existing queue, assess queue reload during a test window. Inspect every command response and resolve failed objects before proceeding.

Agent and tier XML synchronizes with database state. Restarting can reapply XML and overwrite runtime settings or tier positions. If an application manages agents through APIs, decide which fields belong to XML and which to runtime management. A shared multi-server state architecture is outside this single-server example.

Test the caller and agents

Dial 7190 from the third extension. Verify music, agent ringing, answer, two-way speech and normal hangup. After wrap-up time, the agent should accept another call. While waiting, inspect callcenter_config queue list members training@default.

Pause 7101 with callcenter_config agent set status agent7101 On Break, and restore it with callcenter_config agent set status agent7101 Available. Enter the full status text in fs_cli and verify with callcenter_config agent get status agent7101. A new test call should be handled by 7102 when eligible.

For a waiting caller with no offer, inspect registration, agent status, tier association and wrap-up or retry delays. An unanswered offer can change eligibility; inspect callcenter_config agent list before changing it. Directly calling 7101 from another phone helps isolate the contact path.

To roll back, log out both test agents and wait for the queue and test calls to clear. Remove the 7190 route and reloadxml. Check exact object names before deleting the test tiers and agents and unloading the test queue. Restoring a file also requires synchronizing runtime state. Preserve other business queues.

The next installment changes dispatch strategies, unanswered-offer handling and wrap-up time on this queue.

Sources

FreeSWITCH reference

FreeSWITCH reference


评论