Use events method

Front-end events are actions on the product UI, such as button clicks and changes/updates to the UI field values. Events method is an interface that the developer platform provides, to enable your app to react to front-end events.

To enable your app to react to front-end events, in the app.js file,

  1. Subscribe to the app.initialized event, through an event listener. When the app is initialized, the parent application passes a client reference to the app.
  2. After app initialization,
    1. Use the client reference, subscribe to <Event name> and register a callback method to be executed when the event occurs.
    2. Define the callback method.

When the event occurs, a payload is passed to the callback method. Let us call this payload event. event.type returns the name of the event. The event.helper.getData() helper method returns a JSON object that contains information pertaining to the event. Your app logic can process this data into meaningful results.

Click events

These events occur when a user clicks a button or link on the page. The event.helper.getData() method returns the currentCall object for most of these events.

Change events

These events occur when a user changes the value of a field on the UI.

The event.helper.getData() method returns a JSON object that contains the modified values.

Intercept events

These are events that are paused, while the event listener and the corresponding callback run. The app can choose to allow the original event to complete or block the event.

To enable your app to intercept an event, after app initialization,

  1. Use the client reference, subscribe to event, register a callback method to be executed when the event occurs, and set intercept as true.
  2. Define the callback method.
  3. To allow the event to proceed, use the event.helper.done() helper method.
  4. To prevent the event from completion, use the event.helper.fail(‘errorMessage’) helper method.
  5. To obtain data pertaining to the event, use the event.helper.getData() helper method. If your app is intercepting a click event, the method returns an empty JSON.

conversation_card and widget_conversation_card events

Event nameEvent trigger
Click events
call.holdToggledWhen an agent holds or releases a call.
call.muteToggledWhen an agent mutes or unmutes a call.
call.recordingStartedWhen an agent manually starts call recording.
call.recordingPausedWhen an agent pauses call recording.
call.recordingResumedWhen an agent resumes call recording.
Change events
agent.statusChangedWhen an agent’s status is changed.
call.endedWhen a call is disconnected.
call.contactEditedWhen an agent links another contact to a current call.
call.linkedToAnotherContactWhen an agent links another contact to a current call
Intercept events
call.saveAndCloseWhen an agent clicks the Save and close button.

Event and payload descriptions

call.holdToggled

Use the sample code shown on the right pane > Sample code tab, to enable your app to react to a user's click that puts a call on hold or releases a call on hold.

call.muteToggled

Use the sample code shown on the right pane > Sample code tab, to enable your app to react to a user's click that puts a call on mute or releases a call from mute.

call.recordingStarted

Use the sample code shown on the right pane > Sample code tab, to enable your app to react to a user's click that starts call recording.

call.recordingPaused

Use the sample code shown on the right pane > Sample code tab, to enable your app to react to a user's click that pauses call recording.

call.recordingResumed

Use the sample code shown on the right pane > Sample code tab, to enable your app to react to a user's click that resumes call recording after a pause.

agent.statusChanged

Use the sample code shown on the right pane > Sample code tab, to enable your app to react when a user (agent/admin) changes the agent’s status.

call.Ended

Use the sample code shown on the right pane > Sample code tab, to enable your app to react when the app user ends a call.

call.contactEdited

Use the sample code shown on the right pane > Sample code tab, to enable your app to react when the app user edits the contact details of the contact involved in the call.

Important:Only an app deployed at coversation_card can react to this event.

call.linkedToAnotherContact

Use the sample code shown on the right pane > Sample code tab, to enable your app to react when the app user links the call to another contact.

call.saveAndClose

Use the sample code shown on the right pane > Sample code tab, to enable your app to react when the app user clicks the Save and Close button in the coversation_card or widget_conversation_card.