Events
When the Call Summary and Call Tagging user interface needs to request data or perform an action in the CTI backend, it raises an SDK Event that the Partner Application must listen for.
For example, when an agent puts a call on hold in the Call Summary and Call Tagging user interface , the application would raise an event to request that the Partner Application place the call on hold. Similarly, when agent requests to summarize the call, the application requests the text transcript from the Partner Application by raising an event.
The Partner Application listens for these events and performs the requested action, typically using CTI-provided APIs, and responds by invoking appropriate operations with the requested data.
Supported events include:
- serviceGuideCti:agent:status:update
- serviceGuideCti:call:disconnect
- serviceGuideCti:call:mute
- serviceGuideCti:call:unmute
- serviceGuideCti:call:hold
- serviceGuideCti:call:resume
- serviceGuideCti:request:transcript
- serviceGuideCti:call:wrapUp
- serviceGuideCti:agent:logout
To streamline the event emitting mechanism and provide a consistent way to respond to
these events, the Service Guide SDK is defined as an instance of the
EventEmitter class. Additionally, all of these events are wrapped
inside a single event that is emitted by the SDK and targeted to the CTI iFrame.
Implementers can listen for a single event and inspect the event details to know which
specific event has been requested.
This example shows how to handle events using an SDK instance that was initialized in an earlier code snippet and shows how to invoke another operation on the SDK in response to an event:
// SDK Loading and Initialization code
...
// Assuming the SDK instance is named "serviceGuideSdk"
// Read all CTI specific event names
const events = serviceGuideSdk.getCtiSdkEvents();
// "serviceGuideSdk.getSdkEventName()" gives the single, wrapper event name.
// Since the SDK is an "EventEmitter" instance, you can directly call ".on()" function to subscribe to it.
serviceGuideSdk.on(serviceGuideSdk.getSdkEventName(), async ({eventName, payload}) => {
// "eventName" will contain the actual name of the event listed above that was emitted by Service Guide.
switch (eventName) {
case events.updateAgentStatus: // Refers to the constant defined by Service Guide SDK for the "serviceGuideCti:agent:status:update" event.
// Assuming CTI vendor has below API
if(payload.data.isAgentReady) {
try {
const response = await ctiSdk.ApiClient.markUserReady({...});
if(response.ok) {
// Now let Service Guide know that the agent status has been updated to "ready"
serviceGuideSdk.Ui.agentStatusUpdated({ data: {isAgentReady: true} });
}
} catch (error) {
// Error occurred while updating the agent status in the backend. Let Service Guide know with an error payload.
serviceGuideSdk.Ui.agentStatusUpdated({ error: {isError: true, message: 'READY_STATUS_UPDATE_FAILED'} });
}
} else {
try {
const response = await ctiSdk.ApiClient.markUserBusy({...});
if(response.ok) {
// Now let Service Guide know that the agent status has been marked as "busy"
serviceGuideSdk.Ui.agentStatusUpdated({ data: {isAgentReady: false} });
}
} catch (error) {
// Error occurred while updating the agent status in the backend. Let Service Guide know with an error payload.
serviceGuideSdk.Ui.agentStatusUpdated({ error: {isError: true, message: 'NOT_READY_STATUS_UPDATE_FAILED'} });
}
}
break;
case events.disconnectCall:
// disconnect the call and invoke "endCallSession" operation to let Service Guide know.
break;
case events.requestTranscript:
// Assuming CTI vendor has below API to get Agent transcript
const agentTranscript = await ctiSdk.ApiClient.getInternalTranscript(payload.data.callId);
// Assuming CTI vendor has below API to get Customer transcript
const customerTranscript = await ctiSdk.ApiClient.getExternalTranscript(payload.data.callId);
// map the CTI provided transcript in to the necessary format that Service Guide understands,
// i.e. an array of elements containing "text", "offsetMs" and "channel" properties
const mappedAgentTranscript = mapToOperationFormat(agentTranscript);
const mappedCustomerTranscript = mapToOperationFormat(customerTranscript);
// Provide the transcript to Service Guide as part of "transcriptReceived" operation
serviceGuideSdk.Ui.transcriptReceived({
data: {
agentTranscripts: mappedAgentTranscript,
customerTranscripts: mappedCustomerTranscript
}
});
break;
...
}
});
// You can also take modularized approach and define multiple "handlers" to handle specific event
serviceGuideSdk.on(serviceGuideSdk.getSdkEventName(), handleAgentStatusUpdate);
serviceGuideSdk.on(serviceGuideSdk.getSdkEventName(), handleTranscriptGeneration);
...
// and define individual handlers above as
const handleAgentStatusUpdate = async ({eventName, payload}) => {
if (eventName === events.updateAgentStatus) {
... // update agent status and let Service Guide know.
}
});
const handleTranscriptGeneration = async ({eventName, payload}) => {
if (eventName === events.requestTranscript) {
... // Retrieve the transcripts and send them to Service Guide.
}
});
Event: serviceGuideCti:agent:status:update
This table provides additional details about the serviceGuideCti:agent:status:update event:
| Description | Payload | Parameter Description | Notes |
|---|---|---|---|
|
This event is raised when an agent updates their status to Ready or Not Ready, indicating whether they are ready to receive another call. The Partner Application should call the appropriate CTI-specific API to mark the agent's presence as defined in the payload. |
|
isAgentReady: Whether the agent is ready to receive calls. |
The partner application should respond to this event by invoking "agentStatusUpdated" operation. This should be done after receiving a confirmation from the CTI backend that the update was successful, otherwise invoke it with an error payload. |
Event: serviceGuideCti:call:disconnect
This table provides additional details about the serviceGuideCti:call:disconnect event:
| Description | Payload | Parameter Description | Notes |
|---|---|---|---|
| This event is raised by Service Guide when the agent disconnects the call. |
|
callId: A unique identifier representing the call session that needs to be disconnected. |
The partner application should respond to this event by invoking "endCallSession" operation. This should be done after receiving a confirmation from the CTI backend that the call was actually disconnected, otherwise invoke it with an error payload. |
Event: serviceGuideCti:call:mute
This table provides additional details about the serviceGuideCti:call:mute event:
| Description | Payload | Parameter Description | Notes |
|---|---|---|---|
| This event is raised by Service Guide when the agent wants to mute their audio on the call. |
|
callId: A unique identifier for the call to be muted. |
The partner application should respond to this event by invoking "callMuted" operation. This should be done after receiving a confirmation from the CTI backend that the call was actually muted, otherwise invoke it with an error payload. |
Event: serviceGuideCti:call:unmute
This table provides additional details about the serviceGuideCti:call:unmute event:
| Description | Payload | Parameter Description | Notes |
|---|---|---|---|
| This event is raised by Service Guide when the agent wants to reconnect their audio after it has been muted. |
|
callId: A unique identifier for the call to be un-muted. |
The partner application should respond to this event by invoking "callUnmuted" operation. This should be done after receiving a confirmation from the CTI backend that the call was actually unmuted, otherwise invoke it with an error payload. |
Event: serviceGuideCti:call:hold
This table provides additional details about the serviceGuideCti:call:hold event:
| Description | Payload | Parameter Description | Notes |
|---|---|---|---|
| This event is raised by Service Guide when the agent places the customer on hold. |
|
callId: A unique identifier for the call to be placed on hold. |
The Partner Application should respond to this event by invoking "callOnHold" operation. This should be done after receiving a confirmation from the CTI backend that the call was actually placed on hold, otherwise invoke it with an error payload. |
Event: serviceGuideCti:call:resume
This table provides additional details about the serviceGuideCti:call:resume event:
| Description | Payload | Parameter Description | Notes |
|---|---|---|---|
| This event is raised by Service Guide when the agent removes the hold placed on the call. |
|
callId: A unique identifier for the call to be resumed. |
The partner application should respond to this event by invoking "callResumed" operation. This should be done after receiving a confirmation from the CTI backend that the call that was previously put on hold was actually resumed (hold was lifted), otherwise invoke it with an error payload. |
Event: serviceGuideCti:request:transcript
This table provides additional details about the serviceGuideCti:request:transcript event:
| Description | Payload | Parameter Description | Notes |
|---|---|---|---|
| This event is raised by Service Guide when an agent requests the call transcript. |
|
callId: A unique identifier for the call to be answered. |
The Partner Application should respond to this event by invoking "transcriptReceived" operation. This should be done after collecting the relevant transcript from the CTI backend. If for some reason, the transcript cannot be collected, the partner application should invoke the operation with an error payload. |
Event: serviceGuideCti:call:wrapUp
This table provides additional details about the serviceGuideCti:call:wrapUp event:
| Description | Payload | Parameter Description | Notes |
|---|---|---|---|
|
After ending the call, when the agent finishes the after-call work and is ready to move to the next call, this event allows the partner application to capture any after-call work details (wrap up) in the CTI backend. Depending upon the CTI Vendor, this might not be a mandatory operation. Utilities should handle this event after consulting the CTI Vendor documentation. |
|
callId: A unique identifier for the call for which the wrapup should be done. agentNotes: Any notes an agent might have collected during the call. This is included to capture any after-call notes (if the CTI Vendor makes it mandatory). This is optional and may or may not be present. tags: An array of strings representing the call topics that the agent wants to capture as part of wrap up. These are optional and may or may not be present. |
The partner application should respond to this event by invoking "callWrappedUp" operation. This should be done after receiving a confirmation from the CTI backend that the wrapup update was successful. If the update was not successful, the partner application should invoke the operation with an error payload. |
Event: serviceGuideCti:agent:logout
This table provides additional details about the serviceGuideCti:agent:logout event:
| Description | Payload | Parameter Description | Notes |
|---|---|---|---|
| This event is raised when an agent logs out of the Service Guide. The partner application may wish to perform cleanup as part of logout or it may wish to perform a logout of its own to end the authenticated session it may have established at the beginning. This event should be used to initiate that logout and cleanup process. | None | Not Applicable |
The Partner Application should respond to this event by invoking "loggedOut" operation, only after necessary cleanup was done. Service Guide application will wait a certain amount of time to let the partner application finish the cleanup. The partner application must invoke the "loggedOut" operation within that time. If not done, Service Guide will assume that the cleanup was already done and will proceed to complete the logout process on the Service Guide side. |
