Skip to content

cxCallControl

Auto-generated documentation from JSDoc comments

Classes

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

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>>

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.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');

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 };
}

Kind: global class

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>

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);