onToolbarAgentCommand

This event subscription should be added as part of initialization of MCA integration in the CTI application.

This event is used to pass interaction commands to the application from CTI. This is a controllable event. So, if a 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 (for example, getActiveInteractionCommands) in the event response and pass outData for that command by resolving the promise with that outData. The event subscription should be added only once, during initialization of the MCA code for CTI integrations.

Note: The user will get this event notification only once for a session.

Here's a Typescript example for adding subscription for onToolbarAgentCommand 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('onToolbarAgentCommand') as IMcaEventRequest;
    phoneContext.subscribe(request, (response: IEventResponse) => {
        const dataUpdateResponse = response as IMcaOnToolbarAgentCommandEventResponse;
        const data: IMcaOnToolbarAgentCommandDataResponse = dataUpdateResponse.getResponseData();
        const command: string = data.getCommand();
        return new Promise((resolve, reject) => {
            switch (command) {
                case "makeAvailable":
                    break;
                case "makeUnavailable":
                    break;
                case "getActiveInteractionCommands":
                    const outData = {
                        'channel': 'PHONE',
                        'supportedCommands': [{
                            'name': "hold", 'toggleCommand': "unhold", 'defaultEnabled': true,
                            'defaultVisible': true, 'displayName': "Hold", 'position': 1, 'icon': ""
                        },
                        {
                            'name': "unhold", 'toggleCommand': "hold", 'defaultEnabled': false,
                            'defaultVisible': false, 'displayName': "Off Hold", 'position': 1, 'icon': ""
                        },
                        {
                            'name': "mute", 'toggleCommand': "unmute", 'defaultEnabled': true,
                            'defaultVisible': true, 'displayeName': "Mute", 'position': 2, 'icon': ""
                        },
                        {
                            'name': "unmute", 'toggleCommand': "mute", 'defaultEnabled': false,
                            'defaultVisible': false, 'displayName': "Unmute", 'position': 2, 'icon': ""
                        },
                        {
                            'name': "record", 'toggleCommand': "stopRecord", 'defaultEnabled': true,
                            'defaultVisible': true, 'displayName': "Record", 'position': 3, 'icon': ""
                        },
                        {
                            'name': "stopRecord", 'toggleCommand': "record", 'defaultEnabled': false,
                            'defaultVisible': false, 'displayName': "Stop Recording", 'position': 3, 'icon': ""
                        },
                        {
                            'name': "transfer", 'toggleCommand': null, 'defaultEnabled': true,
                            'defaultVisible': true, 'displayName': "Transfer", 'position': 4, 'icon': ""
                        },
                        {
                            'name': "disconnect", 'toggleCommand': null, 'defaultEnabled': true,
                            'defaultVisible': true, 'displayName': "Hang Up", 'position': 5, 'icon': ""
                        }]
                    };
                    data.setOutdata(outData);
                    break;
            }
            data.setResult('success');
            resolve(data);
        });
    });

Here's a JavaScript example for adding subscription for onToolbarAgentCommand 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('onToolbarAgentCommand');
phoneContext.subscribe(request, (response) => {
    const dataUpdateResponse = response;
    const data = dataUpdateResponse.getResponseData();
    const command = data.getCommand();
    return new Promise((resolve, reject) => {
        switch (command) {
            case "makeAvailable":
                break;
            case "makeUnavailable":
                break;
            case "getActiveInteractionCommands":
                const outData = {
                    'channel': 'PHONE',
                    'supportedCommands': [{
                        'name': "hold", 'toggleCommand': "unhold", 'defaultEnabled': true,
                        'defaultVisible': true, 'displayName': "Hold", 'position': 1, 'icon': ""
                    },
                    {
                        'name': "unhold", 'toggleCommand': "hold", 'defaultEnabled': false,
                        'defaultVisible': false, 'displayName': "Off Hold", 'position': 1, 'icon': ""
                    },
                    {
                        'name': "mute", 'toggleCommand': "unmute", 'defaultEnabled': true,
                        'defaultVisible': true, 'displayeName': "Mute", 'position': 2, 'icon': ""
                    },
                    {
                        'name': "unmute", 'toggleCommand': "mute", 'defaultEnabled': false,
                        'defaultVisible': false, 'displayName': "Unmute", 'position': 2, 'icon': ""
                    },
                    {
                        'name': "record", 'toggleCommand': "stopRecord", 'defaultEnabled': true,
                        'defaultVisible': true, 'displayName': "Record", 'position': 3, 'icon': ""
                    },
                    {
                        'name': "stopRecord", 'toggleCommand': "record", 'defaultEnabled': false,
                        'defaultVisible': false, 'displayName': "Stop Recording", 'position': 3, 'icon': ""
                    },
                    {
                        'name': "transfer", 'toggleCommand': null, 'defaultEnabled': true,
                        'defaultVisible': true, 'displayName': "Transfer", 'position': 4, 'icon': ""
                    },
                    {
                        'name': "disconnect", 'toggleCommand': null, 'defaultEnabled': true,
                        'defaultVisible': true, 'displayName': "Hang Up", 'position': 5, 'icon': ""
                    }]
                };
                data.setOutdata(outData);
                break;
        }
        data.setResult('success');
        resolve(data);
    });
});