onToolbarInteractionCommand
Once a call is received at the Fusion application, the Fusion application can accept, reject or disconnect an active call.
The onToolbarInteractionCommand is fired from the Fusion application with this information (accept, reject or disconnect). This is a controllable event. So, if the user wants to control this event by either resolving or rejecting it, they must pass a promise as the return of this event callback function. On notification of this event subscription, user can check the command in the event response. Commands supported are, accept, disconnect, reject and setActive.
These commands corresponds to accept disconnect reject operations agent might make in the Fusion application. User can wire up their logic for each of these commands, on the callback of this event response. The event subscription should be added only once, during initialization of the MCA code for CTI integrations.
Example Use Case
When a CTI supplier makes a call request, we should start a NewCommAction Request to Fusion application, using UEF publish api. This will show a call notification in Fusion application to either accept or decline the call. Now, Agent can either accept this call or decline this call. According to the mentioned action from agent, the CTI integration should either call api to make the call connection for call accept action by agent or, the CTI integration should reject the entire call request for decline action by agent.
In this scenario, onToolbarAgentCommand will give a notification to the CTI integration application about the choice agent has made, ie, either accept or decline and based on that CTI integration can wire up the logic to either call UEF StartComm Api to enable call connection, or call UEF CloseComm API to reject the call entirely.
Here's a Typescript example for adding subscription for onToolbarInteractionCommand event.
/// <reference path="uiEventsFramework.d.ts"/>
const uiEventsFrameworkInstance: IUiEventsFrameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('appname', 'v1');
const multiChannelAdaptorContext: IMultiChannelAdaptorContext = await uiEventsFrameworkInstance.getMultiChannelAdaptorContext();
const phoneContext: IPhoneContext = await multiChannelAdaptorContext.getCommunicationChannelContext('PHONE') as IPhoneContext;
const request: IMcaEventRequest = uiEventsFrameworkInstance.requestHelper.createSubscriptionRequest('onToolbarInteractionCommand') as IMcaEventRequest;
phoneContext.subscribe(request, (response: IEventResponse) => {
const dataUpdateResponse = response as IMcaOnToolbarInteractionCommandEventResponse;
const data: IMcaOnToolbarInteractionCommandDataResponse = dataUpdateResponse.getResponseData();
const command: string = data.getCommand();
return new Promise((resolve, reject) => {
switch (command) {
case "accept":
// publish startCommEvent action
break;
case "disconnect":
// publish closeCommEvent with proper reason
break;
case "reject":
// publish closeCommEvent with proper reason
break;
}
data.setResult('success');
resolve(data);
});
});
Here's a JavaScript example adding subscription for onToolbarInteractionCommand event.
const uiEventsFrameworkInstance = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('appname', 'v1');
const multiChannelAdaptorContext = await uiEventsFrameworkInstance.getMultiChannelAdaptorContext();
const phoneContext = await multiChannelAdaptorContext.getCommunicationChannelContext('PHONE');
const request = uiEventsFrameworkInstance.requestHelper.createSubscriptionRequest('onToolbarInteractionCommand');
phoneContext.subscribe(request, (response) => {
const dataUpdateResponse = response;
const data = dataUpdateResponse.getResponseData();
const command = data.getCommand();
return new Promise((resolve, reject) => {
switch (command) {
case "accept":
// publish startCommEvent action
break;
case "disconnect":
// publish closeCommEvent with proper reason
break;
case "reject":
// publish closeCommEvent with proper reason
break;
}
data.setResult('success');
resolve(data);
});
});