logo

Download Here

The dist directory contains the compiled and compressed code, which can be directly integrated into your project. If you make modifications to the code, you'll need to compile it first. The compilation method is explained here.

!!!Note: The call component and udesk system can only exist in one place. Logging in at one place will log out the other.

!!!Note: Version 2.0 of the call component has introduced a separate API file usage method, which is similar to the component. The explanation is at the bottom of the document.

Example

Direct Usage

1. Import the content of the dist directory into your project, and copy the fonts directory to your project's static resource directory.

<!--  Import CSS -->
<link rel="stylesheet" type="text/css" href="./css/callcenter-component.css">
<!--  Import JS -->
<script src='./callcenter-component.js'></script>

2. Initialize the component

Before initializing, please obtain the agent_api_token here.

<script>
var callComponent = new UdeskCallcenterComponent({
    container: document.body,    // Component container
    token: 'xxxxxxxx',           // Agent token obtained through login interface (i.e., agent_api_token)
    subDomain: 'demo',           // Subdomain registered in udesk, e.g., if login address is demo.udesk.cn, fill in 'demo' here
    showManualScreenPop:true,    // Whether to enable the 'manual screen pop' function
    onScreenPop: function(conversation){},  // Method triggered by screen pop event
    onHangup: function(conversation){}
});
</script>

Options

PropertyTypeRequiredDefaultDescription
containerDocumentYesContainer for the call component
tokenStringYesAgent token (i.e., agent_api_token) obtained through login interface. Obtain here
subDomainStringYesSubdomain registered in udesk. For example, if the login address is demo.udesk.cn, fill in 'demo' here
showManualScreenPopStringNofalseWhether to enable the 'manual screen pop' function
onScreenPop(conversation)functionNoScreen pop event
onRinging(conversation)functionNoRinging event, triggered when the phone rings
onTalking(conversation)functionNoCall event, triggered when the call is answered
onHangup(conversation)functionNoHang-up event, triggered when the call is hung up
onWorkStatusChange(status)functionNoTriggered when the agent's status changes
onWorkWayChange(way)functionNoTriggered when the agent's online mode changes
onDropCall(result)functionNoCallback function after clicking the hang-up button in the call component
onInitSuccess()functionNoTriggered when initialization data is successfully retrieved
onInitFailure()functionNoTriggered when initialization data retrieval fails
onTokenExpired(callback:(newToken:string)=>void)functionNoTriggered when the token expires. The parameter is a callback method. Call this callback method to refresh the token
onIvrCallResult(result:{code:number})functionNoIVR call result, code is 1000 when successful
onResumeAgentResult(result:{code:number})functionNoResult of resuming agent, code is 1000 when successful

Methods

makeCall(number, options)

Make a call

number string - (Required) Phone number

options object
This parameter is an object and can take the following parameters:

options.biz_id string
This field is specified by you and can be any string. It will be carried with this id when call event is pushed

answer()

Answer the call when ringing.
Only effective when the online status is web phone.

destroy()

Destroy the call component

setWorkStatus(status)

Set the agent's online status: idle, busy, wrap-up, offline, break, etc.

status String - Agent status, can only be idle, busy, wrap-up, offline

setWorkingWay(workingWay)

Set the agent's online mode: IP phone, mobile, web phone

workingWay String - Agent online mode, can only be fixed_voip_online, phone_online, voip_online

setupDefaultNumber(number_id,success_callback,failure_callback)

Set a new relay number

number_id number Relay number id
success_callback function Callback when request succeeds
failure_callback function Callback when request fails

hangup(success_callback, failure_callback)

Hang up the current call. The successCallback parameter indicates whether the request was sent successfully, and the actual hang-up is subject to the onDropCall event.

success_callback function Callback when request succeeds
failure_callback function Callback when request fails

getCallNumbers()

Returns the list of relay numbers: {id: number, number: string, name: string, memo: string}[]

PropertyDescription
idRelay number id
numberPhone number
nameName
memoNote

getAutomaticCallNumGroup()

Returns the phone group of customers for automatic dialing tasks. This data is only available when the phone rings and it is an automatic dialing task. For example: {ad_task_id:1,customer_id:2,numbers:["18812345678", "18712345678"]}

Note: This field is only populated when the phone rings and it is an automatic dialing task. Otherwise, this field is empty. Details are as follows:

PropertyDescription
ad_task_idTask id
customer_idCustomer id
numbers["18812345678", "18712345678"] # Number/number group

startIvrCalling(ivrNode:{transfer_mode:"agent_hold"|"agent_hangup",id:string})

Start IVR call, parameter is ivrId

holdCallSelect(successCallback:()=>void, failureCallback:()=>void)

Hold the call

recoveryCallSelect(successCallback:()=>void, failureCallback:()=>void)

Recover the call

transferToGroup(groupId:number|string, successCallback:(res)=>void, failureCallback:(res)=>void)

Transfer to a customer service group

successCallback only indicates that the request was successful. Whether the transfer was successful is determined by getting the result in onTransferResult.

transferToExternalPhone(phoneNumber:string, successCallback:(res)=>void,failureCallback:(res)=>void)

Transfer to an external line

successCallback only indicates that the request was successful. Whether the transfer was successful is determined by getting the result in onTransferResult.

start

ConsultingToExternalPhone(phoneNumber:string, successCallback:(res)=>void,failureCallback:(res)=>void) Start consulting an external line

successCallback only indicates that the request was successful. Whether the consultation was successful is determined by getting the result in onConsultResult.

startThreeWayCallingToExternalPhone(phoneNumber: string, successCallback:(res)=>void, failureCallback:(res)=>void)

Start a three-way call with an external line

successCallback only indicates that the request was successful. Whether the three-way call was successful is determined by getting the result in onThreeWayCallingResult.

transferAfterConsult(agentId: string)

Transfer after consulting

agentId: Agent ID

threeWayCallingAfterConsult(agentId: string)

Three-way call after consulting

agentId: Agent ID

transferAfterThreeWayCalling(agentId: string)

Transfer after three-way calling

agentId: Agent ID

setupDefaultNumber(phoneNumberId: string|number, successCallback:(res)=>void, failureCallback:(res)=>void)

Set the main caller number for outgoing calls. The first parameter is the relay number ID

getCallNumbers():Object[]

Get the available relay numbers

Conversation Object

The conversation object passed into the screen pop event contains the following parameters:

PropertyDescription
call_idCall ID
conversation_idConversation record ID
call_typeCall type, can only be one of the following values: inbound, outbound, inbound (transfer), inbound (three-way), inbound (consult), inbound (intercept), inbound (monitoring), inbound (forced interruption)
customer_phone_numberCustomer number
customer_phone_locationLocation
queue_nameSource queue
queue_overflowOverflow queue
queue_statusQueue status
queue_timeQueue duration (seconds)
agent_idAgent ID
agent_nameAgent name
agent_emailAgent email
ring_timeRing start time, example: 2017-03-09T14:34:24+08:00
ivr_variablesVariables saved in smart routing, format variable_name:[variable_value1][,variable_name2:[variable_value2]...], example: "x:1,y:2,aa:1,bb:2,cc:,variable2:2"
display_nameRelay number
device_infoAgent online mode
categoryCall type: consult (consultation), consult_outline (consultation external line), three_party (three-way), three_party_outline (three-way external line), listening (listening), barge_in (intrusion), whisper (whisper), transfer (transfer), transfer_outline (transfer external line), substitute (interception), transfer_after_consult (transfer after consultation), three_party_after_consult (three-way after consultation), transfer_after_three_party (transfer after three-way), requeue (requeue)
dtmfdtmf
multi_ring_countSequential ringing count
relevant_agentRelated agent

Call API

1. Import call-api.js from the dist directory into your project

<!--  Import JS -->
<script src="./js/call-api.js"></script>

2. Token initialization is required before use

Please obtain the agent_api_token first, as described here.

<script>
window.callAPI.tokenInit(
        '88354be49e4aa632bdbfb8a60bcae04ec157fad4b4fa554daebae3de1d7bc8de9cc80e9f3c39174cb45d3c3ab52fdcfdaf1216ff2dedc11aa13a1b14e89819065a547cf2',
        'linapp',
        function(callback) {
            setTimeout(function() {
                callback('f3ebff04e6cf899cac39da98bcb1ccdd77e9c8ccd94fa70419668c4bb6510b5fe277cb786662b4c6173706fa2915e9184619f42b766f76226f043693cca1dbdf5a2e1d49');
            }, 1000);
        }
    )
</script>

tokenInit Initialization Parameters

Method

tokenInit(token,subDomain,onTokenExpired)

Initialize token and subDomain for the API. Note: token initialization is required before calling the API.

Parameter Description

PropertyTypeRequiredDescription
tokenStringYesAgent token, as described here
subDomainStringYesSubdomain registered in udesk. For example, if the login address is demo.udesk.cn, fill in 'demo' here
onTokenExpired(result)functionNoCallback function when token expires

setMonitorWorkStatus(agent_no,workStatus,successCallback,failureCallback)

Switch the online status of another agent, such as idle, busy, offline, break, etc. For custom breaks, please refer to another method.

setMonitorWorkRestingStatus(agent_no,cc_custom_state_id,successCallback,failureCallback)

Switch the status of custom breaks for other agents. For switching between idle, busy, offline, and break, please refer to another method.

setMonitorAgentWorkWay(agent_no, agent_work_way,successCallback,failureCallback)

Switch the device for other agents, such as IP phone, mobile, web phone

monitorAgentListeing(agent_no,successCallback,failureCallback)

Listen to other agents

monitorAgentInterpose(agent_no,successCallback,failureCallback)

Intrude on other agents

monitorAgentSubstitute(agent_no,successCallback,failureCallback)

Intercept other agents

Parameter Description

PropertyTypeRequiredDescription
agent_nonumberYesAgent ID
workStatusStringYesAgent status, can only be idle, busy, resting, offline
cc_custom_state_idnumberYesID of the custom break state
agent_work_waystringYesDevice status, can only be fixed_voip_online, phone_online, voip_online
successCallbackfunctionNoCallback function when the request is successful
failureCallbackfunctionNoCallback function when the request fails

Browser Compatibility

IEfirefoxchromesafariopera
101116612.10

How to Compile

1. Install Node.js

Download and install

2. Install Webpack

The project is bundled with webpack, so you need to install webpack first.

npm install -g webpack

3. Install Dependencies

Navigate to the project directory and run the following command:

npm install

4. Compile, Bundle, and Minify

webpack