通过拨打快捷码轻松切换分机状态
转译自:Ilias Liotis,3CX 三级支持人员
这套脚本允许用户通过拨打自定义快捷码来更改自己的分机状态(包括:空闲/Available、离开/Away、办公时间外/Out of Office、自定义 1/Custom 1 或自定义 2/Custom 2)。用户无需打开 3CX 客户端界面,即可快速更新个人的状态信息。
系统内还包含预置的修改状态快捷码,可以用来替代自定义快捷码。该脚本展示了呼叫处理脚本(Call Processing Scripts)的灵活性,并且可以根据更多功能需求进行拓展修改。
如何设置分机状态变更脚本
- 进入 管理后台(Admin Console) > 集成(Integrations) > 呼叫脚本(Call Scripts)。
- 点击 从应用商店添加(Add from Store),选择 设置分机空闲状态(Set Extension Available Status)。
- 指定一个易于识别的名称,例如 “空闲”。
- 设置触发条件:当用户拨打特定快捷码时运行此脚本 。
- 添加一个您自定义的快捷码,例如 57。
- 选择系统全局 (System Wide)。
如何为其他状态设置脚本
- 按照上述相同的步骤操作。
- 在第 3 步中,为每个脚本使用唯一的名称,例如 “setaway”。
- 在第 5 步中,为每个脚本分配唯一的快捷码,例如:58 代表办公时间外,59 代表自定义 1。
为什么使用此脚本
- 快速更新状态:无需打开 Web 客户端或移动端 App 即可切换个人状态。
- 高度自定义:可根据实际需求灵活定制快捷码及其对应的分机状态。
- 扩展性强:可根据后续需求增加更多脚本,轻松扩充功能。
脚本示例
免责声明! 此脚本仅供参考。如需最新版本,请从应用商店下载。
脚本:空闲(Available)
using System;
using System.Threading.Tasks;
using TCX.Configuration;
using CallFlow;
using System.Linq;
using System.Collections.Generic;
namespace dummy
{
public class SetAvailableStatus : ScriptBase<SetAvailableStatus>
{
public override async Task<bool> StartAsync()
{
var profileName = “Available”;
var prompt = “ST_AVAILABLE_SET”;
//—–call is direct from the extension and profile extension has required profile
if (MyCall.Caller.DN is Extension ext
&& MyCall.ReferredByDN is not DN
&& ext.FwdProfiles.FirstOrDefault(x=>x.Name.Equals(profileName)) is FwdProfile fwdProfile)
{
//set current status
ext.CurrentProfile = fwdProfile;
//reset profile override
ext.ResetCurrentProfileOverride();
ext.Save();
//—-play system prompt about current status
try
{
MyCall.Info($”Extension {ext.Number} is set to {profileName}”);
await MyCall.AssureMedia()
.ContinueWith(_ => MyCall.PlayPrompt(ext.GetPropertyValue(“PROMPTSETID”), , PlayPromptOptions.Blocked))
.Unwrap();
}
catch
{
//ignore prompt playback failures. action is performed
}
//we made modifications
return true;
}
//we did not make any modifications
return false;
}
}
}
脚本:离开(Away)
using System;
using System.Threading.Tasks;
using TCX.Configuration;
using CallFlow;
using System.Linq;
using System.Collections.Generic;
namespace dummy
{
public class SetAwayStatus : ScriptBase<SetAwayStatus>
{
public override async Task<bool> StartAsync()
{
var profileName = “Away”;
var prompt = “ST_AWAY_SET”;
//—–call is direct from the extension and profile extension has required profile
if (MyCall.Caller.DN is Extension ext
&& MyCall.ReferredByDN is not DN
&& ext.FwdProfiles.FirstOrDefault(x=>x.Name.Equals(profileName)) is FwdProfile fwdProfile)
{
//set current status
ext.CurrentProfile = fwdProfile;
//reset profile override
ext.ResetCurrentProfileOverride();
ext.Save();
//—-play system prompt about current status
try
{
MyCall.Info($”Extension {ext.Number} is set to {profileName}”);
await MyCall.AssureMedia()
.ContinueWith(_ => MyCall.PlayPrompt(ext.GetPropertyValue(“PROMPTSETID”), , PlayPromptOptions.Blocked))
.Unwrap();
}
catch
{
//ignore prompt playback failures. action is performed
}
//we made modifications
return true;
}
//we did not make any modifications
return false;
}
}
}
脚本:办公时间外(Out of office)
using System;
using System.Threading.Tasks;
using TCX.Configuration;
using CallFlow;
using System.Linq;
using System.Collections.Generic;
namespace dummy
{
public class SetDNDStatus : ScriptBase<SetDNDStatus>
{
public override async Task<bool> StartAsync()
{
var profileName = “Out of office”;
var prompt = “ST_OUTOFFICE_SET”;
//—–call is direct from the extension and profile extension has required profile
if (MyCall.Caller.DN is Extension ext
&& MyCall.ReferredByDN is not DN
&& ext.FwdProfiles.FirstOrDefault(x=>x.Name.Equals(profileName)) is FwdProfile fwdProfile)
{
//set current status
ext.CurrentProfile = fwdProfile;
//reset profile override
ext.ResetCurrentProfileOverride();
ext.Save();
//—-play system prompt about current status
try
{
MyCall.Info($”Extension {ext.Number} is set to {profileName}”);
await MyCall.AssureMedia()
.ContinueWith(_ => MyCall.PlayPrompt(ext.GetPropertyValue(“PROMPTSETID”), , PlayPromptOptions.Blocked))
.Unwrap();
}
catch
{
//ignore prompt playback failures. action is performed
}
//we made modifications
return true;
}
//we did not make any modifications
return false;
}
}
}
脚本:自定义 1(Custom 1)
using System;
using System.Threading.Tasks;
using TCX.Configuration;
using CallFlow;
using System.Linq;
using System.Collections.Generic;
namespace dummy
{
public class SetCustom1Status : ScriptBase<SetCustom1Status>
{
public override async Task<bool> StartAsync()
{
var profileName = “Custom 1”;
var prompt = “ST_CUSTOM1_SET”;
//—–call is direct from the extension and profile extension has required profile
if (MyCall.Caller.DN is Extension ext
&& MyCall.ReferredByDN is not DN
&& ext.FwdProfiles.FirstOrDefault(x=>x.Name.Equals(profileName)) is FwdProfile fwdProfile)
{
//set current status
ext.CurrentProfile = fwdProfile;
//reset profile override
ext.ResetCurrentProfileOverride();
ext.Save();
//—-play system prompt about current status
try
{
MyCall.Info($”Extension {ext.Number} is set to {profileName}”);
await MyCall.AssureMedia()
.ContinueWith(_ => MyCall.PlayPrompt(ext.GetPropertyValue(“PROMPTSETID”), , PlayPromptOptions.Blocked))
.Unwrap();
}
catch
{
//ignore prompt playback failures. action is performed
}
//we made modifications
return true;
}
//we did not make any modifications
return false;
}
}
}
脚本:自定义 2(Custom 2)
using System;
using System.Threading.Tasks;
using TCX.Configuration;
using CallFlow;
using System.Linq;
using System.Collections.Generic;
namespace dummy
{
public class SetCustom2Status : ScriptBase<SetCustom2Status>
{
public override async Task<bool> StartAsync()
{
var profileName = “Custom 2”;
var prompt = “ST_CUSTOM2_SET”;
//—–call is direct from the extension and profile extension has required profile
if (MyCall.Caller.DN is Extension ext
&& MyCall.ReferredByDN is not DN
&& ext.FwdProfiles.FirstOrDefault(x=>x.Name.Equals(profileName)) is FwdProfile fwdProfile)
{
//set current status
ext.CurrentProfile = fwdProfile;
//reset profile override
ext.ResetCurrentProfileOverride();
ext.Save();
//—-play system prompt about current status
try
{
MyCall.Info($”Extension {ext.Number} is set to {profileName}”);
await MyCall.AssureMedia()
.ContinueWith(_ => MyCall.PlayPrompt(ext.GetPropertyValue(“PROMPTSETID”), , PlayPromptOptions.Blocked))
.Unwrap();
}
catch
{
//ignore prompt playback failures. action is performed
}
//we made modifications
return true;
}
//we did not make any modifications
return false;
}
}
}
参与互动
关注我们的互动频道,我们通过视频、图片、文档,包括召开技术及市场交流会议的形式,方便你了解及掌握 3CX 最新的资讯与技术信息,同时非常欢迎您在我们的媒体平台进行留言。



