cxCallControl
Auto-generated documentation from JSDoc comments
Classes¶
- cxCallControlC5
- .activeCalls([companyId]) ⇒
Promise.<Array.<object>> - .originate(companyId, class4ServerAlias, internalDestination, cli, destinationNumber, [vars]) ⇒
Promise.<EventEmitter> - .kill_call(uuid) ⇒
Promise.<object> - .recordStart(uuid, filename) ⇒
Promise.<object> - .recordStop(uuid) ⇒
Promise.<object> - .queueCount([queueName]) ⇒
Promise.<Array.<object>>|string|string|number|number|number|number|number|number - .getQueue([queueName]) ⇒
Promise.<Array.<object>> - .queueAddAgent(queueName, username, [wrapUpTime]) ⇒
Promise.<void> - .queueRemoveAgent(queueName, username) ⇒
Promise.<void> - .ccQueueCount(queueId) ⇒
Promise.<string> - .ccQueueListMembers(queueId) ⇒
Promise.<string> - .ccQueueListAgents(queueId) ⇒
Promise.<string> - .ccQueueListTiers(queueId) ⇒
Promise.<string> - .ccAgentSetStatus(queueId, agentName, [status]) ⇒
Promise.<string> - .ccAgentGetStatus(queueId, agentName) ⇒
Promise.<string>
- .activeCalls([companyId]) ⇒
- cxCallControlC4
- .registrations([username]) ⇒
Promise.<Array.<object>>
- .registrations([username]) ⇒
- cxCallControlAI
- .originate(companyId, class4ServerAlias, agentDest, cli, destinationNumber, [vars]) ⇒
Promise.<EventEmitter> - .activeCalls(agentDest, [query], [count]) ⇒
Promise.<(Array.<object>|number)>
- .originate(companyId, class4ServerAlias, agentDest, cli, destinationNumber, [vars]) ⇒
Constants¶
Functions¶
cxCallControlC5¶
Call Control for ConnexCS Class 5 (PBX/Softswitch) systems. Provides call origination, active call monitoring, and queue management.
The C5 function returns an object with the following methods:
- activeCalls() - Get active calls
- originate() - Originate outbound calls
- queueCount() - Get queue statistics
- getQueue() - Get detailed queue information
- queueAddAgent() - Add an agent to a queue
- queueRemoveAgent() - Remove an agent from a queue
- recordStart() - Start recording an active call
- recordStop() - Stop recording an active call
- ccQueueCount() - Get Call Center queue caller/agent counts
- ccQueueListMembers() - List Call Center queue members
- ccQueueListAgents() - List Call Center queue agents
- ccQueueListTiers() - List Call Center queue tiers
- ccAgentSetStatus() - Set a Call Center agent's status
- ccAgentGetStatus() - Get a Call Center agent's status
Example - Call Origination¶
import { C5 } from 'cxCallControl';
export async function main() {
const companyId = '12345';
const class4Alias = 'test3';
const internalDest = '100';
const cliNumber = '9876543210';
const destNumber = '441234567890';
const vars = { foo: 'bar' };
// Connect to Class 5 server(s)
const c5 = await C5(['am1fs1']);
// Originate a call
const callEmitter = await c5.originate(
companyId,
class4Alias,
internalDest,
cliNumber,
destNumber,
vars
);
// Listen for call events
callEmitter.on('CHANNEL_PROGRESS', (data) => {
console.log('Progress event:', data);
});
callEmitter.on('CHANNEL_ANSWER', () => {
console.log('Call answered');
});
callEmitter.on('CHANNEL_HANGUP_COMPLETE', (data) => {
console.log('Call ended:', data);
});
}
Example - Queue Management¶
import { C5 } from 'cxCallControl';
export async function main() {
const companyId = 12345;
try {
const c5 = await C5(['am1fs1']);
// Get all active calls
const allActive = await c5.activeCalls();
console.log('All active calls:', allActive);
// Get active calls for a specific company
const activeForCompany = await c5.activeCalls(companyId);
console.log(`Active calls for company ${companyId}:`, activeForCompany);
// Add an agent to a queue with 60 second wrap-up time
await c5.queueAddAgent('myQueue', 'adam', 60);
// Get all queue statistics
const allQueues = await c5.queueCount();
console.log('Queue stats:', allQueues);
// Remove the agent from the queue
await c5.queueRemoveAgent('myQueue', 'adam');
return { allActive, allQueues, activeForCompany };
} catch (error) {
console.error('Error in C5 flow:', error);
throw error;
}
}
Kind: global class
- cxCallControlC5
- .activeCalls([companyId]) ⇒
Promise.<Array.<object>> - .originate(companyId, class4ServerAlias, internalDestination, cli, destinationNumber, [vars]) ⇒
Promise.<EventEmitter> - .kill_call(uuid) ⇒
Promise.<object> - .recordStart(uuid, filename) ⇒
Promise.<object> - .recordStop(uuid) ⇒
Promise.<object> - .queueCount([queueName]) ⇒
Promise.<Array.<object>>|string|string|number|number|number|number|number|number - .getQueue([queueName]) ⇒
Promise.<Array.<object>> - .queueAddAgent(queueName, username, [wrapUpTime]) ⇒
Promise.<void> - .queueRemoveAgent(queueName, username) ⇒
Promise.<void> - .ccQueueCount(queueId) ⇒
Promise.<string> - .ccQueueListMembers(queueId) ⇒
Promise.<string> - .ccQueueListAgents(queueId) ⇒
Promise.<string> - .ccQueueListTiers(queueId) ⇒
Promise.<string> - .ccAgentSetStatus(queueId, agentName, [status]) ⇒
Promise.<string> - .ccAgentGetStatus(queueId, agentName) ⇒
Promise.<string>
- .activeCalls([companyId]) ⇒
cxCallControlC5.activeCalls([companyId]) ⇒ Promise.<Array.<object>>¶
Get active calls on the Class 5 server(s)
Kind: static method of cxCallControlC5
Returns: Promise.<Array.<object>> - Array of active call objects
| Param | Type | Default | Description |
|---|---|---|---|
| [companyId] | number | boolean |
false |
Filter by Company ID, or false for all companies |
Example
import { C5 } from 'cxCallControl';
const c5 = await C5(['am1fs1']);
// Get all active calls
const allActiveCalls = await c5.activeCalls();
// Get active calls for a specific company
const companyActiveCalls = await c5.activeCalls(12345);
cxCallControlC5.originate(companyId, class4ServerAlias, internalDestination, cli, destinationNumber, [vars]) ⇒ Promise.<EventEmitter>¶
Originate an outbound call
Kind: static method of cxCallControlC5
Returns: Promise.<EventEmitter> - EventEmitter that fires call lifecycle events
Emits: event:CHANNEL_OUTGOING - When the call is initiated, event:CHANNEL_PROGRESS - When the call starts ringing, event:CHANNEL_ANSWER - When the call is answered, event:CALL_UPDATE - When call state changes, event:CHANNEL_HANGUP_COMPLETE - When the call ends, event:CHANNEL_DESTROY - When the call channel is destroyed
| Param | Type | Default | Description |
|---|---|---|---|
| companyId | string | number |
Company ID that owns the call | |
| class4ServerAlias | string |
Alias of the Class 4 server to route the call through | |
| internalDestination | string |
Destination for the B-leg after connection (e.g., extension, IVR, queue) | |
| cli | string |
Caller Line Identification (CLI) number to display | |
| destinationNumber | string |
External phone number to dial (E.164 format recommended) | |
| [vars] | object |
{} |
Custom variables to pass with the call |
Example
import { C5 } from 'cxCallControl';
const c5 = await C5(['am1fs1']);
const callEmitter = await c5.originate(
'105979',
'test3',
'7900',
'9876543210',
'441234567890',
{ foo: 'bar' }
);
callEmitter.on('CHANNEL_PROGRESS', (data) => {
console.log('Ringing', data);
});
callEmitter.on('CHANNEL_ANSWER', () => {
console.log('Call Answered');
});
callEmitter.on('CHANNEL_HANGUP_COMPLETE', (data) => {
console.log('Call Ended', data);
});
cxCallControlC5.kill_call(uuid) ⇒ Promise.<object>¶
Hang up an ongoing call.
Kind: static method of cxCallControlC5
Returns: Promise.<object> - Call UUID and the server(s) that confirmed the hangup
| Param | Type | Description |
|---|---|---|
| uuid | string |
Call UUID (uniqueID from originate() or uuid from activeCalls()) |
Example
const c5 = await C5(['am1fs1']);
const call = await c5.originate('105979', 'test3', '7900', '9876543210', '441234567890');
await c5.kill_call(call.uniqueID);
cxCallControlC5.recordStart(uuid, filename) ⇒ Promise.<object>¶
Start recording an active call
Records the full session (both directions mixed). The recording is written to
<accountId>/<customerId>/<YYYY-MM-DD>/<filename>.wav, with the customer ID and date
resolved from the live channel.
Kind: static method of cxCallControlC5
Returns: Promise.<object> - Result with the resolved path and the server(s) that started recording
| Param | Type | Description |
|---|---|---|
| uuid | string |
Call UUID (the uniqueID from originate() or a uuid from activeCalls()) |
| filename | string |
Recording file name without extension (.wav is appended). Must not contain /.. |
Example
import { C5 } from 'cxCallControl';
const c5 = await C5(['am1fs1']);
const call = await c5.originate('105979', 'test3', '7900', '9876543210', '441234567890');
call.on('CHANNEL_ANSWER', async () => {
await c5.recordStart(call.uniqueID, 'support-call-001');
});
cxCallControlC5.recordStop(uuid) ⇒ Promise.<object>¶
Stop recording an active call
Stops every recording on the channel.
Kind: static method of cxCallControlC5
Returns: Promise.<object> - Result object containing the uuid
| Param | Type | Description |
|---|---|---|
| uuid | string |
Call UUID (the uniqueID from originate() or a uuid from activeCalls()) |
Example
import { C5 } from 'cxCallControl';
const c5 = await C5(['am1fs1']);
await c5.recordStop(call.uniqueID);
cxCallControlC5.queueCount([queueName]) ⇒ Promise.<Array.<object>> | string | string | number | number | number | number | number | number¶
Get queue statistics and agent counts
Kind: static method of cxCallControlC5
Returns: Promise.<Array.<object>> - Array of queue statistics objectsstring - return[].server - Server namestring - return[].name - Queue namenumber - return[].caller_count - Number of callers waitingnumber - return[].agent_count - Total agents in queuenumber - return[].idle_agent_count - Agents available to take callsnumber - return[].off_hook_agent - Agents currently on callsnumber - return[].on_hook_agent - Agents on hooknumber - return[].ring_agent_count - Agents being rung
| Param | Type | Default | Description |
|---|---|---|---|
| [queueName] | string |
"''" |
Queue name to filter by, or empty for all queues |
Example
import { C5 } from 'cxCallControl';
const c5 = await C5(['am1fs1']);
// Get all queue statistics
const allQueues = await c5.queueCount();
// Get specific queue statistics
const queue = await c5.queueCount('support-queue');
// Example response:
// [{
// server: 'am1fs1',
// name: 'support-queue',
// caller_count: 3,
// agent_count: 5,
// idle_agent_count: 2,
// off_hook_agent: 3,
// on_hook_agent: 0,
// ring_agent_count: 0
// }]
cxCallControlC5.getQueue([queueName]) ⇒ Promise.<Array.<object>>¶
Get detailed queue information including members and callers
Kind: static method of cxCallControlC5
Returns: Promise.<Array.<object>> - Array of queue detail objects
| Param | Type | Default | Description |
|---|---|---|---|
| [queueName] | string |
"''" |
Queue name to filter by, or empty for all queues |
Example
import { C5 } from 'cxCallControl';
const c5 = await C5(['am1fs1']);
// Get all queues with details
const allQueues = await c5.getQueue();
// Get specific queue details
const queue = await c5.getQueue('support-queue');
cxCallControlC5.queueAddAgent(queueName, username, [wrapUpTime]) ⇒ Promise.<void>¶
Add an on-hook agent to a queue
Kind: static method of cxCallControlC5
| Param | Type | Default | Description |
|---|---|---|---|
| queueName | string |
Name of the queue to add the agent to | |
| username | string |
Username of the agent to add | |
| [wrapUpTime] | number |
60 |
Wrap-up time in seconds after each call |
Example
import { C5 } from 'cxCallControl';
const c5 = await C5(['am1fs1']);
// Add agent with default 60 second wrap-up time
await c5.queueAddAgent('support-queue', 'joe');
// Add agent with custom wrap-up time
await c5.queueAddAgent('sales-queue', 'alice', 30);
cxCallControlC5.queueRemoveAgent(queueName, username) ⇒ Promise.<void>¶
Remove an on-hook agent from a queue
Kind: static method of cxCallControlC5
| Param | Type | Description |
|---|---|---|
| queueName | string |
Name of the queue to remove the agent from |
| username | string |
Username of the agent to remove |
Example
import { C5 } from 'cxCallControl';
const c5 = await C5(['am1fs1']);
// Remove agent from queue
await c5.queueRemoveAgent('support-queue', 'joe');
cxCallControlC5.ccQueueCount(queueId) ⇒ Promise.<string>¶
Get caller and agent counts for a Call Center queue
Kind: static method of cxCallControlC5
Returns: Promise.<string> - Raw count response from the Call Center module
| Param | Type | Description |
|---|---|---|
| queueId | string |
Call Center queue UUID |
Example
import { C5 } from 'cxCallControl';
const c5 = await C5(['am1fs1']);
const count = await c5.ccQueueCount('7b3e2c9a-1f4d-4a6b-8c2e-9d0f1a2b3c4d');
cxCallControlC5.ccQueueListMembers(queueId) ⇒ Promise.<string>¶
List the members (agents) of a Call Center queue
Kind: static method of cxCallControlC5
Returns: Promise.<string> - Raw member list response from the Call Center module
| Param | Type | Description |
|---|---|---|
| queueId | string |
Call Center queue UUID |
Example
import { C5 } from 'cxCallControl';
const c5 = await C5(['am1fs1']);
const members = await c5.ccQueueListMembers('7b3e2c9a-1f4d-4a6b-8c2e-9d0f1a2b3c4d');
cxCallControlC5.ccQueueListAgents(queueId) ⇒ Promise.<string>¶
List the agents assigned to a Call Center queue
Kind: static method of cxCallControlC5
Returns: Promise.<string> - Raw agent list response from the Call Center module
| Param | Type | Description |
|---|---|---|
| queueId | string |
Call Center queue UUID |
Example
import { C5 } from 'cxCallControl';
const c5 = await C5(['am1fs1']);
const agents = await c5.ccQueueListAgents('7b3e2c9a-1f4d-4a6b-8c2e-9d0f1a2b3c4d');
cxCallControlC5.ccQueueListTiers(queueId) ⇒ Promise.<string>¶
List the tiers of a Call Center queue
Kind: static method of cxCallControlC5
Returns: Promise.<string> - Raw tier list response from the Call Center module
| Param | Type | Description |
|---|---|---|
| queueId | string |
Call Center queue UUID |
Example
import { C5 } from 'cxCallControl';
const c5 = await C5(['am1fs1']);
const tiers = await c5.ccQueueListTiers('7b3e2c9a-1f4d-4a6b-8c2e-9d0f1a2b3c4d');
cxCallControlC5.ccAgentSetStatus(queueId, agentName, [status]) ⇒ Promise.<string>¶
Set the status of an agent in a Call Center queue
Kind: static method of cxCallControlC5
Returns: Promise.<string> - Raw response from the Call Center module
| Param | Type | Default | Description |
|---|---|---|---|
| queueId | string |
Call Center queue UUID (used to resolve the PBX server) | |
| agentName | string |
Name of the agent to update | |
| [status] | string |
"'Available'" |
New agent status (e.g. 'Available', 'On Break', 'Logged Out') |
Example
import { C5 } from 'cxCallControl';
const c5 = await C5(['am1fs1']);
await c5.ccAgentSetStatus('7b3e2c9a-1f4d-4a6b-8c2e-9d0f1a2b3c4d', 'joe', 'Available');
cxCallControlC5.ccAgentGetStatus(queueId, agentName) ⇒ Promise.<string>¶
Get the status of an agent in a Call Center queue
Kind: static method of cxCallControlC5
Returns: Promise.<string> - Raw agent status response from the Call Center module
| Param | Type | Description |
|---|---|---|
| queueId | string |
Call Center queue UUID (used to resolve the PBX server) |
| agentName | string |
Name of the agent to query |
Example
import { C5 } from 'cxCallControl';
const c5 = await C5(['am1fs1']);
const status = await c5.ccAgentGetStatus('7b3e2c9a-1f4d-4a6b-8c2e-9d0f1a2b3c4d', 'joe');
cxCallControlC4¶
Call Control for ConnexCS Class 4 (Carrier-grade) systems. Provides SIP registration management and monitoring.
The C4 function returns an object with the following methods:
- registrations() - Get SIP registrations
Example¶
import { C4 } from 'cxCallControl';
export async function main() {
// Connect to Class 4 server(s)
const c4 = await C4(['test2']);
// Get all SIP registrations
const allRegistrations = await c4.registrations();
console.log('All registrations:', allRegistrations);
// Get registrations for a specific user/extension
const userRegistrations = await c4.registrations('1000');
console.log('User registrations:', userRegistrations);
return { allRegistrations, userRegistrations };
}
cxCallControlC4.registrations([username]) ⇒ Promise.<Array.<object>>¶
Get SIP registrations
Kind: static method of cxCallControlC4
Returns: Promise.<Array.<object>> - Array of registration objects
| Param | Type | Default | Description |
|---|---|---|---|
| [username] | string | boolean |
false |
Filter by username/extension, or false for all registrations |
Example
import { C4 } from 'cxCallControl';
const c4 = await C4(['test2']);
// Get all registrations
const allRegistrations = await c4.registrations();
console.log(allRegistrations);
// Get registrations for a specific user/extension
const userRegistrations = await c4.registrations('1000');
console.log(userRegistrations);
cxCallControlAI¶
Call Control for ConnexCS AI Agent systems. Enables originating calls through AI agents and monitoring active AI-handled calls.
Example¶
import { AI } from 'cxCallControl';
export async function main() {
const ai = await AI();
const callEmitter = await ai.originate(
'105979',
'myC4Server',
'Agent12345',
'9876543210',
'441234567890',
{ campaign: 'outbound-sales' }
);
callEmitter.on('CONNECTED', (data) => {
console.log('AI call connected:', data);
});
}
Kind: global class
- cxCallControlAI
- .originate(companyId, class4ServerAlias, agentDest, cli, destinationNumber, [vars]) ⇒
Promise.<EventEmitter> - .activeCalls(agentDest, [query], [count]) ⇒
Promise.<(Array.<object>|number)>
- .originate(companyId, class4ServerAlias, agentDest, cli, destinationNumber, [vars]) ⇒
cxCallControlAI.originate(companyId, class4ServerAlias, agentDest, cli, destinationNumber, [vars]) ⇒ Promise.<EventEmitter>¶
Originate an AI-handled outbound call
Kind: static method of cxCallControlAI
Returns: Promise.<EventEmitter> - EventEmitter that fires call lifecycle events
Emits: event:PROGRESS - Call is progressing, event:CONNECTED - Call connected to AI agent, event:REJECTED - Call was rejected, event:ERROR - An error occurred, event:FAILED - Call failed, event:TERMINATED - Call terminated, CHANNEL_PROGRESS - Call ringing (C5 compatible), CHANNEL_ANSWER - Call answered (C5 compatible), CHANNEL_HANGUP_COMPLETE - Call ended (C5 compatible)
| Param | Type | Default | Description |
|---|---|---|---|
| companyId | string | number |
Company ID that owns the call | |
| class4ServerAlias | string |
Alias of the Class 4 server to route the call | |
| agentDest | string |
AI Agent destination/ID to handle the call | |
| cli | string |
Caller Line Identification (CLI) number to display | |
| destinationNumber | string |
External phone number to dial | |
| [vars] | object |
{} |
Custom variables to pass with the call |
Example
import { AI } from 'cxCallControl';
const ai = await AI();
const callEmitter = await ai.originate(
'105979',
'myC4Server',
'Agent12345',
'9876543210',
'441234567890',
{ campaign: 'outbound-sales' }
);
// AI-specific events
callEmitter.on('PROGRESS', (data) => {
console.log('Progressing', data);
});
callEmitter.on('CONNECTED', (data) => {
console.log('AI Call Connected', data);
});
callEmitter.on('REJECTED', (data) => {
console.log('Call Rejected', data);
});
// C5 compatible events also available
callEmitter.on('CHANNEL_HANGUP_COMPLETE', (data) => {
console.log('Call Ended', data);
});
cxCallControlAI.activeCalls(agentDest, [query], [count]) ⇒ Promise.<(Array.<object>|number)>¶
Get active AI-handled calls with filtering
Kind: static method of cxCallControlAI
Returns: Promise.<(Array.<object>|number)> - Array of call objects, or count if count=true
| Param | Type | Default | Description |
|---|---|---|---|
| agentDest | string |
AI Agent destination/ID to query | |
| [query] | object |
{} |
Filter criteria (supports any variable set during originate or by AI) |
| [query.callStatus] | string | Array.<string> |
Filter by call status: 'connecting', 'connected', etc. | |
| [query.isAmd] | boolean |
Filter by AMD (Answering Machine Detection) result | |
| [count] | boolean |
false |
If true, returns count only; if false, returns full call data |
Example
import { AI } from 'cxCallControl';
const ai = await AI();
// Get calls with single status filter
const connecting = await ai.activeCalls('Agent12345', { callStatus: 'connecting' });
// Get calls matching multiple statuses (OR)
const active = await ai.activeCalls('Agent12345', {
callStatus: ['connecting', 'connected']
});
// Get calls with multiple filters (AND)
const humanCalls = await ai.activeCalls('Agent12345', {
callStatus: 'connected',
isAmd: false
});
// Get count only
const count = await ai.activeCalls('Agent12345', { callStatus: 'connected' }, true);
// Filter by custom variable set during originate
const campaignCalls = await ai.activeCalls('Agent12345', {
campaign: 'outbound-sales'
}, true);
POLL_INTERVAL_MS¶
Shared event-poll loop for all in-flight calls.
Every originate() used to create its own setInterval, which broke two ways once a script
originated more than a handful of calls at once:
- The sandbox caps concurrent intervals (default 10), so the 11th
originate()threw "Client tries to use setInterval, which exceeds the limit of max 10 ...". - Intervals that outlived their call raced sandbox teardown. The host cleared the timer while a already-dispatched tick still called into the freed context, surfacing as "QuickJSContext had no callback with id -32768".
One interval drains every registered call instead. It starts on the first registration and stops once the last call finishes, so an idle script holds no timer at teardown.
Polling is a synchronous drain of a worker-side buffer (no RPC), so the per-tick cost is a Map walk. The loop runs at the fastest cadence any caller needs (AI's 100ms) rather than the slowest, so moving C5 onto the shared loop does not add latency.
MAX_CALL_POLL_MS¶
Hard cap on how long a single call may be polled, in case no terminal event ever arrives.
registerPoll(key, entry)¶
Register a call to be polled by the shared loop.
Kind: global function
| Param | Type | Description |
|---|---|---|
| key | string |
Unique call identifier (C5 uniqueID / AI id) |
| entry | object |
Poll descriptor |
| entry.emitter | EventEmitter |
Emitter to dispatch this call's events on |
| entry.poll | function |
Drains and returns this call's buffered events |
| entry.eventName | function |
Extracts the event name from a buffered event |
| entry.terminal | Set.<string> |
Event names that end the call |
| [entry.release] | function |
Frees the worker-side buffer for this call |