PBX Features (PBXOperator)

The PBXOperator is used to implement PBX-related features, such as querying CDR records and logging out. This topic describes the attributes, methods, and events related to PBX features (PBXOperator object).

Attributes

Attribute Type Description
username string Username (extension number or email address)
secret string Login signature requested from PBX.
token string The access token requested from PBX.
url URL The URL for accessing your PBX system.
socket WebSocket The socket instance for monitoring PBX status changes and receiving notifications in real-time.
extensionNumber string Extension number.
extensionId string Extension ID.
extensionName string Extension name.

Methods

Methods overview
Initialization
The initialization method is used within Linkus SDK Core.
Note: After successful initialization, any subsequent calls to this method will be invalid and a response Promise.reject will be returned.
Method
init() 
Parameters Null.
Return value
Promise<Result>
Listen for events
Method
on(eventName, listener)
Parameters
  • eventName: The event name.
  • listener: Callback function.
Return value Null.
Note: For more information about the events that you can listen for, see Events.
Query CDR records
Method
cdrQuery(params)
Parameters
params: {
    page: number; //Required, define which page is displayed.
    size: number; //Required, define how many records per page.
    status?: number; // Optional, specify the call type. 0: All; 1: Inbound call; 2: Missed call; 3: Outbound call
    sortBy: 'time' | 'id'; //Required, define the sorting field.
    orderBy?: 'desc' | 'asc'; //Optional, define the display order.
    filter?: string | null; //Optional, define the filtering criteria.
}
Return value
Promise
Return value description
{
    errcode: 0,
    errmsg: "SUCCESS",
    personal_cdr_list: [ //CDR list
        {
            id: 2546, //The sequence number of the record.
            date: "Today", //The date when the call was made or received.
            time: "17:21:39", //The time when the call was made or received.
            timestamp: 1686561699, //The timestamp of the time when the call was made or received.
            number: "1011", // Caller number
            number_type: "extension",
            extension: { //Extension information
                ext_id: 25, //Extension ID
                ext_num: "1011", //Extension number
                caller_id_name: "cwt1011", //Extension name
                photo: "", // Profile image ID
                status: 0, // Online status of the extension endpoints. 0: Offline; 1: Online
                presence_status: "available", //Extension presence status
                presence_information: "",
                first_name: "wt1011", //First name
                last_name: "c", //Last name
                email_addr: "", //Email address
                mobile_number: "", //Mobile number
                enb_vm: 0, //Whether the voicemail is enabled.
                vm_total_count: 0, //The total number of voicemail messages
                vm_unread_count: 0, //The total number of unread voicemail messages
                visable: 0,
                im_id: "xxxxx",
                org_list_info: "",
                is_favorite: 0,
                title: "" //Job title
            },
            status: 3, //Call type. 0: All; 1: Inbound call; 2: Missed call; 3: Outbound call
            talk_duration: 3, //The time between the call answered and the call ended.
            call_type: "Internal", // Communication type: 'Internal' or 'External'
            uniqueid: "1686561699.137", // The unique ID of the CDR.
            disposition: "ANSWERED", // Call status: 'ANSWERED', 'NO ANSWER', 'BUSY', 'FAILED', and 'VOICEMAIL'
            dcontext: "DLPN_DialPlan1010",
            caller_id: "1011", // Caller number
            clid: "\"cwt1010\" <1010>"
        }
    ],
    total_number: 63, //The total number of the queried CDR.
}
Log out
Method
logout()
Parameters Null.
Return value
Promise
Destroy the PBXOperator object
Method
destroy()
Parameters Null.
Return value Null.

Events

Example code
pbx.on('eventName', (data) => {}) 
Runtime error event
Event name runtimeError
Data
PBXResult
Report parameters
{
    code: '',
    msg: '',
}
Note: Refer to the following table for reporting parameter descriptions of the event.
Report parameter description
code msg Description
-106 LINKUS_DISABLED Linkus UC client is disabled.
-107 LOGGED_IN_ELSEWHERE The extension has logged in elsewhere.
-108 EXTENSION_DELETED The extension has been deleted.
-109 RE_LOGIN The extension needs to log in again.
-110 SDK_PLAN_DISABLED PBX plan is NOT Ultimate Plan (UP).
CDR changes event
When this event is triggered, you need to manually call the method to query CDR records.
Event name cdrChange
Data
cdrNotifyData
Report parameters
{
    ext_num: '1001',
    personal_cdr: {
        date:"", // The date when the call was made or received.
        time:"", // The time when the call was made or received.
        timestamp: 1693201380, // The timestamp of the time when the call was made or received. Accurate to the second.
        number: "1001",
        talk_duration:0 // The time between the call answered and the call ended.
    }
}