Example function with TabContext with given Tab Id

The following example shows the syntax for the getTabContext method:

getTabContext(tabId?:string): Promise<ITabContext>;

All the Agent info functions will work with Tab Context.

The following code sample shows an example in TypeScript for getting agent's first name using getFirstName method using tab context of given tab Id.

/// <reference path="uiEventsFramework.d.ts"/>   
const frameworkProvider: IUiEventsFrameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID', 'v1');      
const tabContext: ITabContext = await frameworkProvider.getTabContext('tabId');
const requestObject: IOperationRequest = frameworkProvider.requestHelper.createPublishRequest('GetAgentInfo') as CX_SVC_UI_EVENTS_FRAMEWORK.IOperationRequest;  
tabContext.publish(requestObject).then((message: IOperationResponse) => { 
 	const response: IGetAgentInfoResponse = message as IGetAgentInfoResponse;
	console.log(response.getFirstName()); // usage of getFirstName
});

The following code sample shows an example in JavaScript for getting agent's first name using the getFirstName method.

const frameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID', 'v1');
const tabContext = await frameworkProvider.getTabContext('tabId');
const requestObject = frameworkProvider.requestHelper.createPublishRequest('GetAgentInfo'); tabContext.publish(requestObject).then((response) => {
	console.log(response.getFirstName());
});