business-intelligence-insights
Generate actionable insights from SAP data by analyzing trends, anomalies, correlations, and optimization opportunities to support data-driven business decisions.
Instructions
Generate business insights from SAP data
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | ||
| analysisType | No | Type of analysis to perform | comprehensive |
| entityTypes | No | SAP entity types to analyze | |
| exportFormat | No | Export format (for export action) | json |
| includeRecommendations | No | Include actionable recommendations | |
| insightId | No | Specific insight ID (for get action) | |
| minConfidence | No | Minimum confidence threshold for insights | |
| serviceIds | No | SAP service IDs to include | |
| timeWindow | No | Time window for analysis |
Implementation Reference
- src/tools/realtime-tools.ts:758-870 (handler)The primary handler function that processes input arguments and dispatches to specific actions like 'generate', 'list', 'get', 'configure', and 'export' for business intelligence insights.public async execute(args: z.infer<typeof this.inputSchema>): Promise<any> { logger.info('Generating business intelligence insights', { action: args.action, analysisType: args.analysisType, }); const service = getRealtimeService(); try { switch (args.action) { case 'generate': const insights = this.generateBusinessInsights(args); return { success: true, insights, analysis: { type: args.analysisType, timeWindow: args.timeWindow, entityTypes: args.entityTypes || ['SalesOrder', 'Product', 'Customer'], confidence: 0.85, dataPoints: Math.floor(Math.random() * 10000) + 5000, }, summary: { totalInsights: insights.length, highPriority: insights.filter(i => i.severity === 'critical' || i.severity === 'high') .length, categories: this.categorizeInsights(insights), generatedAt: new Date().toISOString(), }, recommendations: this.generateGlobalRecommendations(insights), }; case 'list': const existingInsights = service.getInsights(); return { success: true, insights: existingInsights.map(insight => ({ insightId: insight.insightId, title: insight.title, type: insight.type, severity: insight.severity, confidence: insight.confidence, generated: insight.generated, expires: insight.expires, })), total: existingInsights.length, active: existingInsights.filter(i => !i.expires || i.expires > new Date()).length, }; case 'get': if (!args.insightId) { throw new Error('Insight ID is required for get action'); } const insight = service.getInsights().find(i => i.insightId === args.insightId); if (!insight) { return { success: false, error: 'Insight not found', insightId: args.insightId, }; } return { success: true, insight: { ...insight, relatedInsights: this.findRelatedInsights(insight, service.getInsights()), actionsPlan: this.generateActionPlan(insight), }, }; case 'configure': const configuration = this.generateInsightConfiguration(args); return { success: true, message: 'Business intelligence engine configured', configuration, status: 'active', }; case 'export': const exportData = this.generateExportData(service.getInsights(), args.exportFormat!); return { success: true, export: exportData, format: args.exportFormat, recordCount: service.getInsights().length, generatedAt: new Date().toISOString(), }; default: throw new Error(`Unknown action: ${args.action}`); } } catch (error: any) { logger.error('Business intelligence error', { error: error.message }); return { success: false, error: error.message, action: args.action, troubleshooting: [ 'Ensure sufficient historical data exists for analysis', 'Verify entity types and service IDs are accessible', 'Check minimum confidence threshold settings', ], }; } }
- src/tools/realtime-tools.ts:717-754 (schema)Zod schema defining the input parameters for the tool, including action types, analysis options, time windows, and export formats.public readonly inputSchema = z .object({ action: z.enum(['generate', 'list', 'get', 'configure', 'export']), entityTypes: z.array(z.string()).optional().describe('SAP entity types to analyze'), serviceIds: z.array(z.string()).optional().describe('SAP service IDs to include'), analysisType: z .enum(['trend', 'anomaly', 'correlation', 'optimization', 'comprehensive']) .optional() .default('comprehensive') .describe('Type of analysis to perform'), timeWindow: z .object({ period: z.enum(['hours', 'days', 'weeks', 'months']), size: z.number().positive(), }) .optional() .default({ period: 'days', size: 7 }) .describe('Time window for analysis'), insightId: z.string().optional().describe('Specific insight ID (for get action)'), minConfidence: z .number() .min(0) .max(1) .optional() .default(0.7) .describe('Minimum confidence threshold for insights'), includeRecommendations: z .boolean() .optional() .default(true) .describe('Include actionable recommendations'), exportFormat: z .enum(['json', 'csv', 'pdf']) .optional() .default('json') .describe('Export format (for export action)'), }) .describe('Business intelligence insights configuration');
- src/tools/realtime-tools.ts:1123-1127 (registration)The tool instance is created and registered within the realtimeAnalyticsTools array export, which collects all realtime analytics tools.new RealTimeDataStreamTool(), new KPIDashboardBuilderTool(), new PredictiveAnalyticsEngineTool(), new BusinessIntelligenceInsightsTool(), ];
- src/tools/realtime-tools.ts:872-898 (helper)Helper method that generates business insights based on analysis type by delegating to specific insight generators and applying confidence filtering.private generateBusinessInsights(args: any): any[] { const insights = []; const analysisTypes = args.analysisType === 'comprehensive' ? ['trend', 'anomaly', 'correlation', 'optimization'] : [args.analysisType]; for (const type of analysisTypes) { switch (type) { case 'trend': insights.push(...this.generateTrendInsights()); break; case 'anomaly': insights.push(...this.generateAnomalyInsights()); break; case 'correlation': insights.push(...this.generateCorrelationInsights()); break; case 'optimization': insights.push(...this.generateOptimizationInsights()); break; } } // Filter by confidence threshold return insights.filter(insight => insight.confidence >= args.minConfidence); }
- src/tools/realtime-tools.ts:900-924 (helper)Helper method generating sample trend insights, such as sales revenue trends, with detailed data, recommendations, and expiration.private generateTrendInsights(): any[] { return [ { insightId: `trend_${Date.now()}_1`, title: 'Sales Revenue Increasing Trend', description: 'Sales revenue has shown a consistent 15.3% upward trend over the past 7 days', type: 'trend_alert', severity: 'medium', confidence: 0.92, data: { metric: 'revenue', trend: 'increasing', percentage: 15.3, timeframe: '7 days', }, recommendations: [ 'Scale inventory to meet increased demand', 'Review pricing strategies for optimization', 'Prepare marketing campaigns to sustain growth', ], generated: new Date(), expires: new Date(Date.now() + DATA_RETENTION.INSIGHTS_MEDIUM), // 48 hours }, ]; }