Publish Action to show multiple insights from an external source

Here's a Typescript example to show Insights, considering recordContext as the current browser tab's active record:

 const frameworkProvider: IUiEventsFrameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID', 'V1');
    const tabContext: ITabContext = await frameworkProvider.getCurrentBrowserTabContext();
    let recordContext: IRecordContext = await tabContext.getActiveRecord();
    let insightContext: IInsightsContext = await recordContext.getInsightsContext();
    let dataFromExternalSource = [
        {
            'id': 'insights1',
            'title': 'custom title 1',
            'message': 'custom message 1',
            'header': 'category 1',
            'actionName': 'Action 1',
            'actionId': 'act1'
        },
        {
            'id': 'insights2',
            'title': 'custom title 2',
            'message': 'custom message 2',
            'header': 'category 2',
            'actionName': 'Action 2',
            'actionId': 'act2',
        }
    ];

    dataFromExternalSource.forEach((element: any) => {
        const payload: IShowInsightsRequest = frameworkProvider.requestHelper.createPublishRequest('ShowInsights') as IShowInsightsRequest;
        payload.setId(element.id);
        payload.setTitle(element.title);
        payload.setMessage(element.message);
        payload.setHeader(element.header);
        (payload.action() as IInsightsActionRequest).setActionDetails(element.actionName, element.actionId);
        insightContext.publish(payload).then((response: IOperationResponse) => {
            const insightsOperationResponse = response as IInsightsOperationResponse;
            console.log((insightsOperationResponse.getResponseData() as IInsightsOperationResponseData).getInsightsId());
        });
    });

Here's a JavaScript example to show Insights, considering recordContext as the current browser tab's active record:

 const frameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID', 'V1');
        const tabContext = await frameworkProvider.getCurrentBrowserTabContext();
        let recordContext = await tabContext.getActiveRecord();
        let insightContext = await recordContext.getInsightsContext();
        let dataFromExternalSource = [
            {
                'id': 'insights1',
                'title': 'custom title 1',
                'message': 'custom message 1',
                'header': 'category 1',
                'actionName': 'Action 1',
                'actionId': 'act1'
            },
            {
                'id': 'insights2',
                'title': 'custom title 2',
                'message': 'custom message 2',
                'header': 'category 2',
                'actionName': 'Action 2',
                'actionId': 'act2',
            }
        ];
        dataFromExternalSource.forEach((element) => {
            const payload = frameworkProvider.requestHelper.createPublishRequest('ShowInsights');
            payload.setId(element.id);
            payload.setTitle(element.title);
            payload.setMessage(element.message);
            payload.setHeader(element.header);
            payload.action().setActionDetails(element.actionName, element.actionId);
            insightContext.publish(payload).then((response) => {
                const insightsOperationResponse = response;
                console.log(insightsOperationResponse.getResponseData().getInsightsId());
            });
        });