Handle outbound calls
This scenario can be divided into four states.
- Start outbound call
- Call accepted by the customer
- Call disconnected by the agent or customer
- Call declined by the customer
Start outbound call
The agent clicks the phone number from the Fusion application and the call state is ringing.
- The agent starts an outbound call from the Fusion application by clicking on
the phone number, launching the onOutgoingEvent event.
The following code can be executed from the partner application to subscribe to onOutgoingEvent event:
// Step 1: Get the proper context const multiChannelAdaptorContext: IMultiChannelAdaptorContext = await uiEventsFrameworkInstance.getMultiChannelAdaptorContext(); const phoneContext: IPhoneContext = await multiChannelAdaptorContext.getCommunicationChannelContext('PHONE') as IPhoneContext; // Step 2: Create the request object const requestObject: IMcaEventRequest = uiEventsFrameworkInstance.requestHelper.createSubscriptionRequest('onOutgoingEvent') as IMcaEventRequest; requestObject.setAppClassification('ORA_SERVICE'); // Step 3: Invoke the API phoneContext.subscribe(requestObject, async (eventResponse: IMcaonOutgoingEventResponse) => { // Use the event response to get the phone number and invoke the initiate call api of CTI vendor });
- The partner application listening for this event then notify the CTI supplier to start the call.
- The partner application will notify the call initiation to the Fusion
application by publishing the newCommEvent action.
The following code can be executed from the partner application to fire a newCommEvent action:
// Step 1: Get the proper context const multiChannelAdaptorContext: IMultiChannelAdaptorContext = await uiEventsFrameworkInstance.getMultiChannelAdaptorContext(); const phoneContext: IPhoneContext = await multiChannelAdaptorContext.getCommunicationChannelContext('PHONE') as IPhoneContext; // Step 2: Create the request object const requestObject: IMcaNewCommEventActionRequest = uiEventsFrameworkInstance.requestHelper.createPublishRequest('newCommEvent') as IMcaNewCommEventActionRequest; // Set request object properties requestObject.setEventId('1'); requestObject.getInData().setInDataValueByAttribute('SVCMCA_ANI', phoneNumber); requestObject.getInData().setInDataValueByAttribute("SVCMCA_COMMUNICATION_DIRECTION", "ORA_SVC_OUTBOUND"); requestObject.setAppClassification('ORA_SERVICE'); // Step 3: Invoke the API phoneContext.publish(requestObject).then((operationResponse: IMcaNewComActionResponse) => { // Handle the custom logic for UI updates here }).catch(() => { })
- The action response from fusion application has the contact details which can be used by the Partner application for rendering the UI.
Call accepted by a customer
- The Customer accepts the incoming call and the CTI supplier notifies the
partner application. The partner application publishes the startCommEvent
action to notify the Fusion application.
The following code can be executed from the partner application to fire a startCommEvent action:
// Step 1: Get the proper context const multiChannelAdaptorContext: IMultiChannelAdaptorContext = await uiEventsFrameworkInstance.getMultiChannelAdaptorContext(); const phoneContext: IPhoneContext = await multiChannelAdaptorContext.getCommunicationChannelContext('PHONE') as IPhoneContext; // Step 2: Create the request object const request: IMcaStartCommEventActionRequest = uiEventsFrameworkInstance.requestHelper.createPublishRequest('startCommEvent') as IMcaStartCommEventActionRequest; request.setAppClassification('ORA_SERVICE'); request.setEventId('1'); // Step 3: Invoke the API phoneContext.publish(request).then((operationResponse: IMcaStartComActionResponse) => { // Extract the required data from response and use for updating the partner app const contactName: string = operationResponse.getResponseData().getData()['SVCMCA_CONTACT_NAME']; // sample for getting the contact name }).catch(() => { });
- On completing the startCommEvent the partner application can update the UI as required to show the in-progress call.
Call disconnected by the agent or customer
- The agent ends the call from the Fusion application which fires
onToolbarInteractionCommand Event with command as disconnect
The following code can be executed from the partner application to subscribe to onToolbarInteractionCommand event:
// Step 1: Get the proper context const multiChannelAdaptorContext: IMultiChannelAdaptorContext = await uiEventsFrameworkInstance.getMultiChannelAdaptorContext(); const phoneContext: IPhoneContext = await multiChannelAdaptorContext.getCommunicationChannelContext('PHONE') as IPhoneContext; // Step 2: Create the request object const requestObject: IMcaEventRequest = uiEventsFrameworkInstance.requestHelper.createSubscriptionRequest('onToolbarInteractionCommand') as IMcaEventRequest; // Step 3: Invoke the API phoneContext.subscribe(requestObject, (eventResponse: IMcaOnToolbarInteractionCommandEventResponse) => { const eventResponseDetails: IMcaOnToolbarInteractionCommandDataResponse = eventResponse.getResponseData(); const command: string = eventResponseDetails.getCommand(); switch (command) { case "accept": // Notify CTI Vendor to accept the call break; case "disconnect": // Notify CTI Vendor to disconnect the call (In this use-case your logic should be here) break; case "reject": // Notify CTI Vendor to reject the call break; } }).catch(() => { })
- The Partner application listening for this event will handle the event by notifying the CTI supplier to disconnect the call.
- Once the call is disconnected the partner application publishes
closeCommEvent to the fusion application with reason as a wrap up.
The following code can be executed from the partner application to fire a closeCommEvent action:
// Step 1: Get the proper context const multiChannelAdaptorContext: IMultiChannelAdaptorContext = await uiEventsFrameworkInstance.getMultiChannelAdaptorContext(); const phoneContext: IPhoneContext = await multiChannelAdaptorContext.getCommunicationChannelContext('PHONE') as IPhoneContext; // Step 2: Create the request object const requestObject: IMcaNewCommEventActionRequest = uiEventsFrameworkInstance.requestHelper.createPublishRequest('closeCommEvent') as IMcaCloseCommEventActionRequest; // Set request object properties, in this scenario we need to set the reason as Wrapup requestObject.setReason("WRAPUP"); // Step 3: Invoke the API phoneContext.publish(requestObject).then((operationResponse: IMcaCloseComActionResponse) => { console.log('closeCommEvent fired', operationResponse); }).catch(() => { })
- The Fusion application performs the wrap up flow and displays a note.
- On the CloseCommEvent response the partner application updates the UI as required.
Call declined by the customer
- The customer rejects the incoming call and the CTI supplier notifies the partner application.
- The partner application updates the UI and publish the closeCommEvent to the
Fusion application.
The following code can be executed from the partner application to fire a closeCommEvent action:
// Step 1: Get the proper context const multiChannelAdaptorContext: IMultiChannelAdaptorContext = await uiEventsFrameworkInstance.getMultiChannelAdaptorContext(); const phoneContext: IPhoneContext = await multiChannelAdaptorContext.getCommunicationChannelContext('PHONE') as IPhoneContext; // Step 2: Create the request object const requestObject: IMcaNewCommEventActionRequest = uiEventsFrameworkInstance.requestHelper.createPublishRequest('closeCommEvent') as IMcaCloseCommEventActionRequest; // Set request object properties, in this scenario we need to set the reason as reject requestObject.setReason("REJECT"); // Step 3: Invoke the API phoneContext.publish(requestObject).then((operationResponse: IMcaCloseComActionResponse) => { console.log('closeCommEvent fired', operationResponse); }).catch(() => { })
- The partner application updates the UI to show that the agent is available.