Updated on 2023-10-12 GMT+08:00

Developing the Function of Registering Listening Events

  1. Register the Init listening event.

    AICCSupport.addHandler('Init',(eventData)=>{console.log('AICC Support Demo Page Init',eventData);});

    Init is the value of the first parameter eventName of the addHandler method.

    eventData is the parameter of the callback function, which is used to return event data to the integrator. The callback function is the second parameter of the addHandler method.

    Table 1 Input parameters of the addHandler method

    Parameter

    Type

    Name

    Mandatory or Not

    Description

    eventName

    String

    Event name

    Yes

    Event name.

    callback(eventData)

    Function

    Event handler

    Yes

    Callback function. (The eventData parameter is used to return data.)

    Table 2 Event names exposed by eventName

    eventName

    Name

    Description

    Init

    Workbench initialization event

    Event triggered when the workbench is opened.

    Ringing

    Inbound call event

    Event triggered when an inbound call is received.

    Talking

    Answering event

    Event triggered when a call is answered.

    Release

    Release event

    Event triggered when a call is released.

    Switch

    User switch event

    Event triggered when an agent switches between multimedia users on the left of the online chat workbench.

    Table 3 Return parameters in eventData of the callback function

    Parameter

    Type

    Name

    Description

    callerNum

    String

    Calling number

    Calling number.

    calledNum

    String

    Called number

    Called number.

    callid

    String

    Session ID

    Session ID.

    Unique ID of the current session in a call. The value must be the same as that of Call S/N on the Customer Contact History > Contact Record page.

    mediaType

    String

    Media type

    The options are audio, video, wechat, email, whatsapp, and web.

    NOTE:

    The mediaType parameter can be returned properly only when you set Type and then Subtype for creating a multimedia skill queue.

    callType

    String

    Call type

    0 indicates an inbound call. 1 indicates an outbound call.

    workNo

    String

    Current agent ID

    Initialization event. Only the agent ID is available.

    calldata

    String

    Call-associated data

    Call-associated data.

  2. Press F12 to open the browser console. If the output log "[AICCSupport Log] -Info- addHandler - add Init handler" can be found, the listening event is registered successfully.