Skip to content

Examples

rUv edited this page Jul 31, 2025 · 2 revisions

Examples

Comprehensive practical examples demonstrating real-world applications of FACT across industries and use cases.

📚 Table of Contents

💰 Financial Analysis Examples

Investment Portfolio Analysis

import asyncio
from datetime import datetime, timedelta
from src.core.driver import get_driver

class PortfolioAnalyzer:
    """Real-time investment portfolio analysis system"""
    
    def __init__(self):
        self.driver = None
        
    async def initialize(self):
        self.driver = await get_driver()
    
    async def analyze_portfolio_performance(self, portfolio_data):
        """Comprehensive portfolio performance analysis"""
        
        query = f"""
        Analyze this investment portfolio performance:
        
        Holdings: {portfolio_data['holdings']}
        Current Values: {portfolio_data['current_values']}
        Purchase Prices: {portfolio_data['purchase_prices']}
        Purchase Dates: {portfolio_data['purchase_dates']}
        Total Portfolio Value: ${portfolio_data['total_value']:,.2f}
        
        Provide detailed analysis including:
        1. Individual stock performance (gains/losses)
        2. Portfolio diversification assessment
        3. Risk-adjusted returns analysis
        4. Sector allocation breakdown
        5. Rebalancing recommendations
        6. Tax implications for potential sells
        7. Market timing insights
        8. Future outlook based on market trends
        """
        
        analysis = await self.driver.process_query(query)
        return analysis
    
    async def risk_assessment(self, portfolio_data, market_conditions):
        """Portfolio risk assessment with market correlation"""
        
        query = f"""
        Perform comprehensive risk assessment for portfolio:
        
        Portfolio: {portfolio_data}
        Current Market Conditions: {market_conditions}
        
        Analyze:
        1. Value at Risk (VaR) calculations
        2. Beta coefficients for each holding
        3. Sector concentration risks
        4. Correlation with market indices
        5. Stress test scenarios (market crash, inflation)
        6. Liquidity risk assessment
        7. Currency exposure risks
        8. Recommended hedging strategies
        """
        
        risk_analysis = await self.driver.process_query(query)
        return risk_analysis
    
    async def generate_trading_signals(self, technical_data, fundamental_data):
        """Generate buy/sell/hold signals based on multiple factors"""
        
        query = f"""
        Generate trading signals based on:
        
        Technical Analysis Data: {technical_data}
        Fundamental Analysis Data: {fundamental_data}
        
        For each stock, provide:
        1. Signal (BUY/SELL/HOLD)
        2. Confidence level (1-10)
        3. Price targets (support/resistance levels)
        4. Entry/exit strategies
        5. Stop-loss recommendations
        6. Time horizon for the trade
        7. Catalysts to watch for
        8. Risk factors that could invalidate the signal
        
        Prioritize by potential return vs risk ratio.
        """
        
        signals = await self.driver.process_query(query)
        return signals

# Example usage
async def portfolio_analysis_example():
    analyzer = PortfolioAnalyzer()
    await analyzer.initialize()
    
    # Sample portfolio data
    portfolio = {
        'holdings': ['AAPL', 'GOOGL', 'MSFT', 'AMZN', 'TSLA'],
        'current_values': [150.50, 2800.25, 380.75, 3300.80, 250.90],
        'purchase_prices': [120.00, 2200.00, 300.00, 2800.00, 180.00],
        'purchase_dates': ['2023-01-15', '2023-02-20', '2023-01-10', '2023-03-05', '2023-02-28'],
        'shares': [100, 10, 50, 20, 40],
        'total_value': 285000.00
    }
    
    # Run comprehensive analysis
    performance = await analyzer.analyze_portfolio_performance(portfolio)
    print("📊 Portfolio Performance Analysis:")
    print(performance)
    
    # Risk assessment
    market_conditions = {
        'sp500_trend': 'bullish',
        'volatility_index': 18.5,
        'interest_rates': 'rising',
        'inflation_rate': 3.2,
        'market_sentiment': 'cautiously optimistic'
    }
    
    risk_report = await analyzer.risk_assessment(portfolio, market_conditions)
    print("\n⚠️ Risk Assessment:")
    print(risk_report)
    
    await analyzer.driver.close()

asyncio.run(portfolio_analysis_example())

Market Sentiment Analysis

class MarketSentimentAnalyzer:
    """Analyze market sentiment from multiple data sources"""
    
    def __init__(self):
        self.driver = None
    
    async def initialize(self):
        self.driver = await get_driver()
    
    async def analyze_news_sentiment(self, news_data, stock_symbol):
        """Analyze news sentiment impact on stock price"""
        
        query = f"""
        Analyze news sentiment for {stock_symbol}:
        
        Recent News Headlines: {news_data['headlines']}
        News Sources: {news_data['sources']}
        Publication Dates: {news_data['dates']}
        Article Snippets: {news_data['snippets']}
        
        Provide:
        1. Overall sentiment score (-100 to +100)
        2. Key positive/negative themes
        3. Credibility assessment of sources
        4. Potential price impact prediction
        5. Timeline for sentiment effects
        6. Comparison with peer company sentiment
        7. Recommendations for investors
        8. Warning signs to monitor
        """
        
        sentiment_analysis = await self.driver.process_query(query)
        return sentiment_analysis
    
    async def social_media_sentiment(self, social_data):
        """Analyze social media sentiment and retail investor behavior"""
        
        query = f"""
        Analyze social media sentiment:
        
        Twitter Mentions: {social_data['twitter_mentions']}
        Reddit Discussion Volume: {social_data['reddit_volume']}
        Popular Hashtags: {social_data['hashtags']}
        Influencer Opinions: {social_data['influencer_posts']}
        Retail Trading Volume: {social_data['retail_volume']}
        
        Determine:
        1. Retail investor sentiment score
        2. Viral trends that could affect stock
        3. Meme stock potential assessment
        4. Social media driven volatility risk
        5. Contrarian investment opportunities
        6. Early warning signals for pump/dump schemes
        7. Correlation with actual trading volume
        """
        
        social_sentiment = await self.driver.process_query(query)
        return social_sentiment

# Example usage
async def sentiment_analysis_example():
    analyzer = MarketSentimentAnalyzer()
    await analyzer.initialize()
    
    # News sentiment analysis
    news_data = {
        'headlines': [
            'Company X reports record quarterly earnings',
            'New product launch exceeds expectations',
            'Regulatory challenges ahead for tech sector',
            'CEO announces major expansion plans'
        ],
        'sources': ['Reuters', 'Bloomberg', 'Wall Street Journal', 'CNBC'],
        'dates': ['2025-01-30', '2025-01-29', '2025-01-28', '2025-01-27'],
        'snippets': [
            'Revenue up 25% year-over-year...',
            'Pre-orders surpass company projections...',
            'Industry faces increased scrutiny...',
            'Strategic investment in emerging markets...'
        ]
    }
    
    sentiment = await analyzer.analyze_news_sentiment(news_data, 'AAPL')
    print("📰 News Sentiment Analysis:")
    print(sentiment)
    
    await analyzer.driver.close()

asyncio.run(sentiment_analysis_example())

📈 Business Intelligence Examples

Sales Performance Dashboard

class SalesAnalyticsDashboard:
    """Comprehensive sales analytics and forecasting system"""
    
    def __init__(self):
        self.driver = None
    
    async def initialize(self):
        self.driver = await get_driver()
    
    async def analyze_sales_performance(self, sales_data):
        """Comprehensive sales performance analysis"""
        
        query = f"""
        Analyze sales performance data:
        
        Monthly Sales: {sales_data['monthly_sales']}
        Sales by Region: {sales_data['regional_sales']}
        Product Performance: {sales_data['product_sales']}
        Sales Team Performance: {sales_data['team_performance']}
        Customer Acquisition: {sales_data['new_customers']}
        Customer Retention: {sales_data['retention_rate']}
        Average Deal Size: {sales_data['avg_deal_size']}
        Sales Cycle Length: {sales_data['sales_cycle']}
        
        Provide detailed analysis:
        1. Year-over-year growth trends
        2. Seasonal patterns identification
        3. Top performing products/regions/salespeople
        4. Underperforming areas requiring attention
        5. Customer lifetime value analysis
        6. Sales funnel conversion rates
        7. Revenue forecasting for next quarter
        8. Actionable recommendations for improvement
        """
        
        analysis = await self.driver.process_query(query)
        return analysis
    
    async def forecast_revenue(self, historical_data, market_factors):
        """Advanced revenue forecasting with market considerations"""
        
        query = f"""
        Generate revenue forecast based on:
        
        Historical Sales Data: {historical_data}
        Market Factors: {market_factors}
        
        Create forecasts for:
        1. Next quarter revenue (with confidence intervals)
        2. Annual revenue projection
        3. Growth rate predictions by product line
        4. Market share evolution forecast
        5. Risk factors that could impact projections
        6. Scenario analysis (best/worst/most likely cases)
        7. Key performance indicators to track
        8. Strategic recommendations to achieve targets
        
        Include statistical confidence levels and methodology explanation.
        """
        
        forecast = await self.driver.process_query(query)
        return forecast
    
    async def customer_churn_analysis(self, customer_data):
        """Predict and analyze customer churn patterns"""
        
        query = f"""
        Analyze customer churn patterns:
        
        Customer Data: {customer_data}
        
        Provide:
        1. Churn probability for each customer segment
        2. Key churn indicators and warning signs
        3. Customer lifetime value by segment
        4. Retention strategy recommendations
        5. Revenue impact of predicted churn
        6. Win-back campaign suggestions
        7. Pricing strategy optimization
        8. Product/service improvement recommendations
        """
        
        churn_analysis = await self.driver.process_query(query)
        return churn_analysis

# Example usage
async def sales_analytics_example():
    dashboard = SalesAnalyticsDashboard()
    await dashboard.initialize()
    
    # Sample sales data
    sales_data = {
        'monthly_sales': [500000, 525000, 480000, 600000, 580000, 620000],
        'regional_sales': {
            'North America': 2800000,
            'Europe': 1900000,
            'Asia Pacific': 1600000,
            'Latin America': 800000
        },
        'product_sales': {
            'Product A': 3200000,
            'Product B': 2100000,
            'Product C': 1800000
        },
        'team_performance': {
            'Team 1': {'sales': 1800000, 'members': 5},
            'Team 2': {'sales': 2200000, 'members': 6},
            'Team 3': {'sales': 1600000, 'members': 4}
        },
        'new_customers': [45, 52, 38, 67, 59, 71],
        'retention_rate': 0.87,
        'avg_deal_size': 12500,
        'sales_cycle': 45  # days
    }
    
    analysis = await dashboard.analyze_sales_performance(sales_data)
    print("📊 Sales Performance Analysis:")
    print(analysis)
    
    await dashboard.driver.close()

asyncio.run(sales_analytics_example())

Customer Behavior Analysis

class CustomerBehaviorAnalyzer:
    """Advanced customer behavior analysis and segmentation"""
    
    def __init__(self):
        self.driver = None
    
    async def initialize(self):
        self.driver = await get_driver()
    
    async def segment_customers(self, customer_data):
        """Intelligent customer segmentation based on behavior"""
        
        query = f"""
        Perform customer segmentation analysis:
        
        Customer Data: {customer_data}
        
        Create meaningful customer segments based on:
        1. Purchase behavior patterns
        2. Product preferences
        3. Engagement levels
        4. Lifetime value
        5. Geographic distribution
        6. Demographic characteristics
        
        For each segment, provide:
        1. Segment name and description
        2. Key characteristics
        3. Size and revenue contribution
        4. Preferred products/services
        5. Communication preferences
        6. Marketing recommendations
        7. Retention strategies
        8. Growth opportunities
        """
        
        segmentation = await self.driver.process_query(query)
        return segmentation
    
    async def analyze_purchase_patterns(self, transaction_data):
        """Analyze customer purchase patterns and preferences"""
        
        query = f"""
        Analyze customer purchase patterns:
        
        Transaction Data: {transaction_data}
        
        Identify:
        1. Seasonal buying patterns
        2. Product affinity groups (items bought together)
        3. Price sensitivity by customer segment
        4. Optimal promotion timing
        5. Cross-sell and upsell opportunities
        6. Customer journey mapping
        7. Repeat purchase probability
        8. Factors influencing purchase decisions
        
        Provide actionable insights for:
        - Inventory management
        - Marketing campaign timing
        - Product bundling strategies
        - Pricing optimization
        """
        
        patterns = await self.driver.process_query(query)
        return patterns

# Example usage
async def customer_behavior_example():
    analyzer = CustomerBehaviorAnalyzer()
    await analyzer.initialize()
    
    # Sample customer data
    customer_data = {
        'demographics': {
            'age_groups': {'18-25': 1200, '26-35': 2800, '36-45': 2100, '46-60': 1800, '60+': 900},
            'income_levels': {'<50k': 2100, '50k-100k': 3500, '100k-150k': 2000, '>150k': 1200},
            'locations': {'urban': 5800, 'suburban': 2400, 'rural': 600}
        },
        'purchase_behavior': {
            'avg_order_value': 125.50,
            'purchase_frequency': 3.2,  # per month
            'preferred_channels': {'online': 0.65, 'in_store': 0.35},
            'seasonal_variance': {'Q1': 0.9, 'Q2': 1.1, 'Q3': 0.8, 'Q4': 1.4}
        },
        'engagement': {
            'email_open_rate': 0.28,
            'social_media_following': 45000,
            'customer_service_contacts': {'satisfaction': 4.2, 'resolution_time': 2.3}
        }
    }
    
    segments = await analyzer.segment_customers(customer_data)
    print("👥 Customer Segmentation:")
    print(segments)
    
    await analyzer.driver.close()

asyncio.run(customer_behavior_example())

⚙️ Data Processing Workflows

ETL Pipeline with FACT

import pandas as pd
from datetime import datetime
import asyncio

class IntelligentETLPipeline:
    """AI-enhanced ETL pipeline with automated data quality checks"""
    
    def __init__(self):
        self.driver = None
        self.processed_records = 0
        self.errors = []
    
    async def initialize(self):
        self.driver = await get_driver()
    
    async def extract_and_validate(self, data_sources):
        """Extract data and perform intelligent validation"""
        
        query = f"""
        Analyze these data sources for extraction:
        
        Data Sources: {data_sources}
        
        For each source, provide:
        1. Data quality assessment
        2. Schema validation
        3. Missing data patterns
        4. Outlier detection
        5. Data freshness check
        6. Format consistency validation
        7. Recommended cleaning procedures
        8. ETL transformation suggestions
        
        Prioritize data quality issues by business impact.
        """
        
        validation_results = await self.driver.process_query(query)
        return validation_results
    
    async def transform_with_business_rules(self, raw_data, business_context):
        """Apply intelligent transformations based on business context"""
        
        query = f"""
        Transform data based on business requirements:
        
        Raw Data Sample: {raw_data[:5]}  # First 5 records
        Business Context: {business_context}
        
        Recommend transformations for:
        1. Data standardization (formats, units, naming)
        2. Business rule application
        3. Calculated field generation
        4. Data enrichment opportunities
        5. Aggregation strategies
        6. Performance optimization
        7. Error handling procedures
        8. Data lineage tracking
        
        Provide specific transformation logic and SQL/Python code where applicable.
        """
        
        transformation_plan = await self.driver.process_query(query)
        return transformation_plan
    
    async def load_optimization(self, target_schema, performance_requirements):
        """Optimize data loading strategy"""
        
        query = f"""
        Optimize data loading strategy:
        
        Target Schema: {target_schema}
        Performance Requirements: {performance_requirements}
        
        Recommend:
        1. Optimal batch sizes
        2. Indexing strategies
        3. Partitioning approaches
        4. Load balancing techniques
        5. Error recovery procedures
        6. Monitoring and alerting setup
        7. Rollback strategies
        8. Performance benchmarks
        
        Consider both speed and data integrity requirements.
        """
        
        load_strategy = await self.driver.process_query(query)
        return load_strategy
    
    async def run_pipeline(self, data_sources, target_config):
        """Execute complete ETL pipeline with AI optimization"""
        
        print("🚀 Starting Intelligent ETL Pipeline")
        
        try:
            # Extract and validate
            print("📥 Extracting and validating data...")
            validation = await self.extract_and_validate(data_sources)
            print(f"✅ Validation complete: {validation}")
            
            # Load sample data for transformation planning
            sample_data = []
            for source in data_sources:
                if source['type'] == 'csv':
                    df = pd.read_csv(source['path']).head()
                    sample_data.extend(df.to_dict('records'))
            
            # Transform
            print("🔄 Planning transformations...")
            business_context = target_config.get('business_context', {})
            transform_plan = await self.transform_with_business_rules(sample_data, business_context)
            print(f"✅ Transformation plan: {transform_plan}")
            
            # Load optimization
            print("📤 Optimizing load strategy...")
            load_plan = await self.load_optimization(
                target_config['schema'], 
                target_config['performance_requirements']
            )
            print(f"✅ Load optimization: {load_plan}")
            
            return {
                'validation_results': validation,
                'transformation_plan': transform_plan,
                'load_strategy': load_plan,
                'status': 'success',
                'timestamp': datetime.now().isoformat()
            }
            
        except Exception as e:
            self.errors.append(str(e))
            return {
                'status': 'failed',
                'errors': self.errors,
                'timestamp': datetime.now().isoformat()
            }

# Example usage
async def etl_pipeline_example():
    pipeline = IntelligentETLPipeline()
    await pipeline.initialize()
    
    # Define data sources
    data_sources = [
        {
            'name': 'sales_data',
            'type': 'csv',
            'path': 'data/sales_2025.csv',
            'expected_columns': ['date', 'customer_id', 'product_id', 'amount', 'region']
        },
        {
            'name': 'customer_data',
            'type': 'database',
            'connection': 'postgres://localhost/customers',
            'table': 'customer_profiles'
        }
    ]
    
    # Target configuration
    target_config = {
        'schema': {
            'sales_fact': ['date', 'customer_key', 'product_key', 'amount', 'region_key'],
            'customer_dim': ['customer_key', 'customer_name', 'segment', 'lifetime_value']
        },
        'performance_requirements': {
            'max_load_time': '30 minutes',
            'availability': '99.9%',
            'concurrent_users': 50
        },
        'business_context': {
            'industry': 'retail',
            'reporting_frequency': 'daily',
            'key_metrics': ['revenue', 'customer_acquisition', 'retention']
        }
    }
    
    # Run pipeline
    results = await pipeline.run_pipeline(data_sources, target_config)
    
    print("\n📊 ETL Pipeline Results:")
    print(f"Status: {results['status']}")
    if results['status'] == 'success':
        print("✅ Pipeline planning completed successfully")
    else:
        print(f"❌ Pipeline failed: {results['errors']}")
    
    await pipeline.driver.close()

asyncio.run(etl_pipeline_example())

Real-time Data Processing

import asyncio
from asyncio import Queue
import json
from datetime import datetime

class RealTimeDataProcessor:
    """Real-time streaming data processor with AI analysis"""
    
    def __init__(self, buffer_size=1000):
        self.driver = None
        self.data_buffer = Queue(maxsize=buffer_size)
        self.processing_stats = {
            'processed': 0,
            'errors': 0,
            'start_time': None
        }
    
    async def initialize(self):
        self.driver = await get_driver()
        self.processing_stats['start_time'] = datetime.now()
    
    async def process_stream_batch(self, data_batch):
        """Process a batch of streaming data with AI analysis"""
        
        query = f"""
        Analyze this real-time data batch:
        
        Data Batch: {data_batch}
        Batch Size: {len(data_batch)}
        
        Perform real-time analysis:
        1. Anomaly detection (identify unusual patterns)
        2. Trend analysis (immediate directional changes)
        3. Alert generation (critical thresholds breached)
        4. Pattern recognition (recurring behaviors)
        5. Predictive insights (short-term forecasts)
        6. Data quality assessment (completeness, accuracy)
        7. Performance metrics (processing efficiency)
        8. Actionable recommendations (immediate actions needed)
        
        Focus on insights that require immediate attention or action.
        """
        
        analysis = await self.driver.process_query(query)
        return analysis
    
    async def detect_anomalies(self, current_data, historical_baseline):
        """Real-time anomaly detection with context"""
        
        query = f"""
        Detect anomalies in real-time data:
        
        Current Data Point: {current_data}
        Historical Baseline: {historical_baseline}
        
        Analyze for:
        1. Statistical anomalies (beyond normal ranges)
        2. Behavioral anomalies (unusual patterns)
        3. Contextual anomalies (unexpected for time/situation)
        4. Collective anomalies (group behavior changes)
        5. Severity assessment (critical/moderate/minor)
        6. Potential causes (likely explanations)
        7. Impact assessment (business consequences)
        8. Recommended actions (immediate response needed)
        
        Provide confidence scores and urgency levels.
        """
        
        anomaly_report = await self.driver.process_query(query)
        return anomaly_report
    
    async def generate_alerts(self, analysis_results):
        """Generate intelligent alerts based on analysis"""
        
        query = f"""
        Generate smart alerts from analysis:
        
        Analysis Results: {analysis_results}
        
        Create alerts for:
        1. Critical issues requiring immediate action
        2. Warning signs that need monitoring
        3. Opportunities for optimization
        4. Performance degradation indicators
        5. Security concerns or threats
        6. Business rule violations
        7. Compliance issues
        8. System health problems
        
        For each alert, provide:
        - Priority level (Critical/High/Medium/Low)
        - Recommended action
        - Expected timeline for resolution
        - Escalation path if unresolved
        """
        
        alerts = await self.driver.process_query(query)
        return alerts
    
    async def stream_processor(self):
        """Main streaming data processor"""
        
        batch_size = 100
        current_batch = []
        
        print("🌊 Starting real-time data processor...")
        
        while True:
            try:
                # Collect data points into batches
                if not self.data_buffer.empty():
                    data_point = await self.data_buffer.get()
                    current_batch.append(data_point)
                    
                    # Process when batch is full or timeout
                    if len(current_batch) >= batch_size:
                        print(f"🔄 Processing batch of {len(current_batch)} items...")
                        
                        # Process batch
                        analysis = await self.process_stream_batch(current_batch)
                        
                        # Generate alerts if needed
                        alerts = await self.generate_alerts(analysis)
                        
                        # Handle critical alerts
                        if 'Critical' in alerts:
                            print(f"🚨 CRITICAL ALERT: {alerts}")
                        
                        # Update stats
                        self.processing_stats['processed'] += len(current_batch)
                        current_batch = []
                        
                        print(f"✅ Batch processed. Total: {self.processing_stats['processed']}")
                
                # Brief pause to prevent CPU overload
                await asyncio.sleep(0.1)
                
            except Exception as e:
                self.processing_stats['errors'] += 1
                print(f"❌ Processing error: {e}")
                await asyncio.sleep(1)  # Wait before retry
    
    async def add_data_point(self, data):
        """Add new data point to processing queue"""
        try:
            await self.data_buffer.put(data)
        except asyncio.QueueFull:
            print("⚠️ Data buffer full, dropping oldest data point")
            # Remove oldest item to make space
            try:
                await self.data_buffer.get_nowait()
                await self.data_buffer.put(data)
            except asyncio.QueueEmpty:
                pass

# Example usage
async def realtime_processing_example():
    processor = RealTimeDataProcessor()
    await processor.initialize()
    
    # Start the stream processor in background
    processor_task = asyncio.create_task(processor.stream_processor())
    
    # Simulate streaming data
    print("📡 Simulating streaming data...")
    
    # Generate sample streaming data
    for i in range(500):
        data_point = {
            'timestamp': datetime.now().isoformat(),
            'metric': 'cpu_usage',
            'value': 45 + (i % 50) + (5 if i % 100 == 0 else 0),  # Simulate anomaly every 100 points
            'server': f'server_{i % 10}',
            'environment': 'production'
        }
        
        await processor.add_data_point(data_point)
        
        # Brief pause between data points
        await asyncio.sleep(0.01)
        
        # Print progress
        if i % 100 == 0:
            print(f"📊 Generated {i} data points")
    
    # Let processor finish current batches
    await asyncio.sleep(5)
    
    # Stop processor
    processor_task.cancel()
    
    # Print final stats
    elapsed = (datetime.now() - processor.processing_stats['start_time']).total_seconds()
    print(f"\n📈 Processing Complete:")
    print(f"  Processed: {processor.processing_stats['processed']} data points")
    print(f"  Errors: {processor.processing_stats['errors']}")
    print(f"  Duration: {elapsed:.1f} seconds")
    print(f"  Rate: {processor.processing_stats['processed'] / elapsed:.1f} points/second")
    
    await processor.driver.close()

asyncio.run(realtime_processing_example())

🔬 Research & Analysis Examples

Academic Research Assistant

class ResearchAssistant:
    """AI-powered research analysis and literature review assistant"""
    
    def __init__(self):
        self.driver = None
    
    async def initialize(self):
        self.driver = await get_driver()
    
    async def analyze_research_papers(self, papers_data):
        """Comprehensive analysis of research papers"""
        
        query = f"""
        Analyze these research papers for systematic review:
        
        Papers Data: {papers_data}
        
        Provide comprehensive analysis:
        1. Key themes and research areas
        2. Methodology comparison across papers
        3. Contradictory findings identification
        4. Research gaps and opportunities
        5. Citation network analysis
        6. Temporal trend analysis
        7. Impact assessment of key papers
        8. Future research directions
        
        Create a synthesis that highlights:
        - Consensus findings
        - Methodological strengths/weaknesses
        - Practical implications
        - Theoretical contributions
        """
        
        analysis = await self.driver.process_query(query)
        return analysis
    
    async def generate_literature_review(self, research_topic, papers_summary):
        """Generate structured literature review"""
        
        query = f"""
        Generate comprehensive literature review for: {research_topic}
        
        Based on papers: {papers_summary}
        
        Structure the review with:
        1. Introduction and scope definition
        2. Theoretical framework overview
        3. Methodological approaches used
        4. Key findings synthesis
        5. Critical analysis of conflicting results
        6. Identification of research gaps
        7. Implications for practice/policy
        8. Future research recommendations
        
        Use academic writing style with proper citations format.
        Highlight both consensus and debate in the field.
        """
        
        literature_review = await self.driver.process_query(query)
        return literature_review
    
    async def research_methodology_advisor(self, research_question, constraints):
        """Provide research methodology recommendations"""
        
        query = f"""
        Recommend research methodology for:
        
        Research Question: {research_question}
        Constraints: {constraints}
        
        Provide detailed recommendations for:
        1. Most appropriate research design
        2. Data collection methods
        3. Sample size calculations
        4. Statistical analysis approaches
        5. Potential biases and mitigation strategies
        6. Ethical considerations
        7. Timeline and resource requirements
        8. Alternative approaches if primary fails
        
        Include pros/cons of each recommendation and cite relevant methodological literature.
        """
        
        methodology_advice = await self.driver.process_query(query)
        return methodology_advice

# Example usage
async def research_assistant_example():
    assistant = ResearchAssistant()
    await assistant.initialize()
    
    # Sample research papers data
    papers_data = {
        'paper_1': {
            'title': 'Machine Learning in Healthcare: A Systematic Review',
            'authors': ['Smith, J.', 'Johnson, M.'],
            'year': 2024,
            'methodology': 'Systematic Review',
            'sample_size': 150,
            'key_findings': 'ML improves diagnostic accuracy by 15-25%',
            'citations': 45
        },
        'paper_2': {
            'title': 'Deep Learning Applications in Medical Imaging',
            'authors': ['Brown, A.', 'Davis, R.'],
            'year': 2023,
            'methodology': 'Meta-analysis',
            'sample_size': 89,
            'key_findings': 'CNN models achieve 92% accuracy in image classification',
            'citations': 78
        },
        'paper_3': {
            'title': 'Ethical Considerations in AI-Driven Healthcare',
            'authors': ['Wilson, K.', 'Taylor, S.'],
            'year': 2024,
            'methodology': 'Qualitative Study',
            'sample_size': 25,
            'key_findings': 'Privacy and bias are primary concerns',
            'citations': 23
        }
    }
    
    # Analyze papers
    analysis = await assistant.analyze_research_papers(papers_data)
    print("📚 Research Papers Analysis:")
    print(analysis)
    
    # Generate literature review
    review = await assistant.generate_literature_review(
        "AI in Healthcare",
        papers_data
    )
    print("\n📖 Literature Review:")
    print(review)
    
    await assistant.driver.close()

asyncio.run(research_assistant_example())

Market Research Analyzer

class MarketResearchAnalyzer:
    """Comprehensive market research analysis and insights generation"""
    
    def __init__(self):
        self.driver = None
    
    async def initialize(self):
        self.driver = await get_driver()
    
    async def analyze_market_opportunity(self, market_data):
        """Comprehensive market opportunity analysis"""
        
        query = f"""
        Analyze market opportunity:
        
        Market Data: {market_data}
        
        Provide comprehensive analysis:
        1. Market size and growth projections
        2. Competitive landscape assessment
        3. Customer segments and needs analysis
        4. Entry barriers and challenges
        5. Revenue potential estimation
        6. Risk factors and mitigation strategies
        7. Go-to-market strategy recommendations
        8. Success metrics and KPIs
        
        Include both quantitative analysis and strategic insights.
        Consider market dynamics, regulatory factors, and technological trends.
        """
        
        opportunity_analysis = await self.driver.process_query(query)
        return opportunity_analysis
    
    async def competitive_intelligence(self, competitors_data):
        """Deep competitive intelligence analysis"""
        
        query = f"""
        Analyze competitive landscape:
        
        Competitors Data: {competitors_data}
        
        Provide intelligence on:
        1. Competitive positioning analysis
        2. Strengths and weaknesses assessment
        3. Pricing strategy comparison
        4. Product/service differentiation
        5. Market share dynamics
        6. Strategic moves and patterns
        7. Vulnerability analysis
        8. Competitive response predictions
        
        Identify white space opportunities and competitive advantages.
        """
        
        competitive_analysis = await self.driver.process_query(query)
        return competitive_analysis
    
    async def customer_insights(self, customer_research_data):
        """Deep customer insights and persona development"""
        
        query = f"""
        Generate customer insights from research:
        
        Customer Research: {customer_research_data}
        
        Develop:
        1. Detailed customer personas
        2. Journey mapping and pain points
        3. Needs hierarchy and prioritization
        4. Decision-making process analysis
        5. Influence factors and triggers
        6. Communication preferences
        7. Value proposition alignment
        8. Retention and loyalty drivers
        
        Include actionable recommendations for product development and marketing.
        """
        
        customer_insights = await self.driver.process_query(query)
        return customer_insights

# Example usage
async def market_research_example():
    analyzer = MarketResearchAnalyzer()
    await analyzer.initialize()
    
    # Sample market data
    market_data = {
        'market_size': '$2.5B annually',
        'growth_rate': '12% CAGR',
        'segments': {
            'enterprise': {'size': '60%', 'growth': '8%'},
            'mid_market': {'size': '30%', 'growth': '15%'},
            'small_business': {'size': '10%', 'growth': '25%'}
        },
        'geography': {
            'north_america': 45,
            'europe': 30,
            'asia_pacific': 20,
            'other': 5
        },
        'trends': [
            'Increasing demand for automation',
            'Cloud-first preferences',
            'Mobile-first approach',
            'AI/ML integration requirements'
        ]
    }
    
    # Analyze opportunity
    opportunity = await analyzer.analyze_market_opportunity(market_data)
    print("🎯 Market Opportunity Analysis:")
    print(opportunity)
    
    await analyzer.driver.close()

asyncio.run(market_research_example())

🎧 Customer Service Automation

Intelligent Support Ticket Classifier

class SupportTicketAnalyzer:
    """AI-powered support ticket classification and routing system"""
    
    def __init__(self):
        self.driver = None
    
    async def initialize(self):
        self.driver = await get_driver()
    
    async def classify_and_route_ticket(self, ticket_data):
        """Classify support ticket and recommend routing"""
        
        query = f"""
        Analyze and classify this support ticket:
        
        Ticket Data: {ticket_data}
        
        Provide classification:
        1. Primary category (Technical/Billing/General/Bug Report/Feature Request)
        2. Secondary subcategory (specific area)
        3. Urgency level (Critical/High/Medium/Low)
        4. Complexity assessment (Simple/Moderate/Complex)
        5. Estimated resolution time
        6. Required expertise level
        7. Recommended routing (team/individual)
        8. Automated resolution potential
        
        Also suggest:
        - Initial response template
        - Troubleshooting steps
        - Similar resolved tickets
        - Escalation triggers
        """
        
        classification = await self.driver.process_query(query)
        return classification
    
    async def generate_response_suggestions(self, ticket_content, customer_history):
        """Generate intelligent response suggestions"""
        
        query = f"""
        Generate customer support response for:
        
        Ticket: {ticket_content}
        Customer History: {customer_history}
        
        Provide:
        1. Personalized greeting acknowledging customer
        2. Problem acknowledgment and empathy
        3. Step-by-step troubleshooting guide
        4. Alternative solutions if primary fails
        5. Timeline expectations
        6. Follow-up plan
        7. Escalation path if needed
        8. Professional closing with next steps
        
        Tone should be helpful, professional, and empathetic.
        Consider customer's technical level and previous interactions.
        """
        
        response_suggestions = await self.driver.process_query(query)
        return response_suggestions
    
    async def analyze_ticket_trends(self, tickets_data):
        """Analyze support ticket trends for insights"""
        
        query = f"""
        Analyze support ticket trends:
        
        Tickets Data: {tickets_data}
        
        Identify:
        1. Most common issue categories
        2. Trend patterns over time
        3. Customer satisfaction correlations
        4. Resolution time patterns
        5. Agent performance insights
        6. Product/service problem areas
        7. Seasonal or cyclical patterns
        8. Root cause analysis opportunities
        
        Recommend:
        - Process improvements
        - Training needs
        - Product/service enhancements
        - Knowledge base updates
        """
        
        trend_analysis = await self.driver.process_query(query)
        return trend_analysis

# Example usage
async def support_ticket_example():
    analyzer = SupportTicketAnalyzer()
    await analyzer.initialize()
    
    # Sample support ticket
    ticket_data = {
        'ticket_id': 'TKT-2025-001',
        'customer_id': 'CUST-456',
        'subject': 'Unable to login after password reset',
        'description': 'Hi, I reset my password yesterday but still cannot log into my account. I\'ve tried multiple times and cleared my browser cache. The error message says "Invalid credentials" even though I\'m sure the password is correct.',
        'customer_tier': 'Premium',
        'product': 'Web Application',
        'submitted_date': '2025-01-31T10:30:00Z',
        'channel': 'email'
    }
    
    customer_history = {
        'previous_tickets': 3,
        'satisfaction_score': 4.2,
        'account_age_months': 18,
        'subscription_tier': 'Premium',
        'last_interaction': '2024-12-15',
        'technical_level': 'intermediate'
    }
    
    # Classify ticket
    classification = await analyzer.classify_and_route_ticket(ticket_data)
    print("🎫 Ticket Classification:")
    print(classification)
    
    # Generate response
    response = await analyzer.generate_response_suggestions(ticket_data['description'], customer_history)
    print("\n💬 Response Suggestions:")
    print(response)
    
    await analyzer.driver.close()

asyncio.run(support_ticket_example())

Customer Sentiment Analysis

class CustomerSentimentAnalyzer:
    """Real-time customer sentiment analysis and alert system"""
    
    def __init__(self):
        self.driver = None
    
    async def initialize(self):
        self.driver = await get_driver()
    
    async def analyze_interaction_sentiment(self, interaction_data):
        """Analyze customer interaction sentiment"""
        
        query = f"""
        Analyze customer sentiment from interaction:
        
        Interaction: {interaction_data}
        
        Provide sentiment analysis:
        1. Overall sentiment score (-100 to +100)
        2. Emotional indicators (frustrated, satisfied, angry, etc.)
        3. Confidence level in assessment
        4. Key sentiment drivers (specific issues/positives)
        5. Escalation risk assessment
        6. Satisfaction prediction
        7. Churn risk indicators
        8. Recommended response approach
        
        Consider:
        - Language tone and word choice
        - Context and interaction history
        - Customer tier and relationship value
        - Product/service specific factors
        """
        
        sentiment_analysis = await self.driver.process_query(query)
        return sentiment_analysis
    
    async def predict_customer_satisfaction(self, interaction_history):
        """Predict customer satisfaction and retention"""
        
        query = f"""
        Predict customer satisfaction based on interaction history:
        
        Interaction History: {interaction_history}
        
        Analyze and predict:
        1. Current satisfaction level (1-10 scale)
        2. Satisfaction trend (improving/declining/stable)
        3. Retention probability (next 12 months)
        4. Likelihood to recommend (NPS prediction)
        5. Key satisfaction drivers
        6. Risk factors for dissatisfaction
        7. Opportunities for improvement
        8. Proactive retention strategies
        
        Provide confidence intervals and methodology explanation.
        """
        
        satisfaction_prediction = await self.driver.process_query(query)
        return satisfaction_prediction

# Example usage
async def sentiment_analysis_example():
    analyzer = CustomerSentimentAnalyzer()
    await analyzer.initialize()
    
    # Sample customer interaction
    interaction_data = {
        'customer_id': 'CUST-123',
        'interaction_type': 'chat',
        'messages': [
            {'sender': 'customer', 'text': 'This is the third time I\'m contacting support about the same issue. This is getting really frustrating.'},
            {'sender': 'agent', 'text': 'I apologize for the inconvenience. Let me look into your previous cases and make sure we resolve this today.'},
            {'sender': 'customer', 'text': 'I hope so. I\'ve been a loyal customer for 3 years and this experience is making me consider switching.'}
        ],
        'duration_minutes': 15,
        'resolution_status': 'in_progress'
    }
    
    # Analyze sentiment
    sentiment = await analyzer.analyze_interaction_sentiment(interaction_data)
    print("😊 Sentiment Analysis:")
    print(sentiment)
    
    await analyzer.driver.close()

asyncio.run(sentiment_analysis_example())

✍️ Content Generation Examples

Marketing Content Generator

class MarketingContentGenerator:
    """AI-powered marketing content creation and optimization"""
    
    def __init__(self):
        self.driver = None
    
    async def initialize(self):
        self.driver = await get_driver()
    
    async def create_campaign_content(self, campaign_brief):
        """Generate comprehensive marketing campaign content"""
        
        query = f"""
        Create marketing campaign content based on brief:
        
        Campaign Brief: {campaign_brief}
        
        Generate:
        1. Campaign tagline and messaging hierarchy
        2. Email marketing templates (subject lines + body)
        3. Social media posts (platform-specific)
        4. Blog post outlines and key points
        5. Ad copy variations (short/medium/long)
        6. Landing page content structure
        7. Video script concepts
        8. Press release template
        
        Ensure content is:
        - Brand-aligned and consistent
        - Target audience appropriate
        - Conversion-optimized
        - Platform-specific when needed
        - A/B test ready with variations
        """
        
        campaign_content = await self.driver.process_query(query)
        return campaign_content
    
    async def optimize_content_performance(self, content_data, performance_metrics):
        """Analyze and optimize content performance"""
        
        query = f"""
        Optimize content based on performance data:
        
        Content: {content_data}
        Performance Metrics: {performance_metrics}
        
        Provide optimization recommendations:
        1. High-performing elements to replicate
        2. Underperforming areas needing improvement
        3. A/B testing suggestions
        4. Content format optimization
        5. Timing and frequency adjustments
        6. Audience targeting refinements
        7. Channel-specific optimizations
        8. Creative variations to test
        
        Include specific changes to implement and expected impact predictions.
        """
        
        optimization_plan = await self.driver.process_query(query)
        return optimization_plan
    
    async def generate_seo_content(self, seo_brief):
        """Generate SEO-optimized content"""
        
        query = f"""
        Create SEO-optimized content:
        
        SEO Brief: {seo_brief}
        
        Generate:
        1. Optimized title tags and meta descriptions
        2. Header structure (H1, H2, H3) with keywords
        3. Content outline with keyword integration
        4. Internal linking opportunities
        5. Featured snippet optimization
        6. Related keywords and semantic terms
        7. Content length recommendations
        8. Image alt text suggestions
        
        Ensure content is:
        - Naturally readable and engaging
        - Search engine optimized
        - User intent focused
        - Competitive advantage driven
        """
        
        seo_content = await self.driver.process_query(query)
        return seo_content

# Example usage
async def content_generation_example():
    generator = MarketingContentGenerator()
    await generator.initialize()
    
    # Sample campaign brief
    campaign_brief = {
        'product': 'AI-powered project management tool',
        'target_audience': 'Software development teams (10-100 people)',
        'campaign_goal': 'Increase trial signups by 40%',
        'key_benefits': ['30% faster project delivery', 'Automated reporting', 'Real-time collaboration'],
        'budget': '$50,000',
        'duration': '3 months',
        'channels': ['email', 'social_media', 'content_marketing', 'paid_ads'],
        'brand_voice': 'Professional yet approachable, tech-savvy, results-focused'
    }
    
    # Generate campaign content
    content = await generator.create_campaign_content(campaign_brief)
    print("📱 Marketing Campaign Content:")
    print(content)
    
    await generator.driver.close()

asyncio.run(content_generation_example())

Technical Documentation Generator

class TechnicalDocumentationGenerator:
    """Automated technical documentation creation and maintenance"""
    
    def __init__(self):
        self.driver = None
    
    async def initialize(self):
        self.driver = await get_driver()
    
    async def generate_api_documentation(self, api_specs):
        """Generate comprehensive API documentation"""
        
        query = f"""
        Generate API documentation from specifications:
        
        API Specifications: {api_specs}
        
        Create documentation including:
        1. API overview and purpose
        2. Authentication methods and examples
        3. Endpoint descriptions with parameters
        4. Request/response examples (JSON)
        5. Error codes and handling
        6. Rate limiting information
        7. SDK usage examples (multiple languages)
        8. Integration tutorials and best practices
        
        Format for developer portal with:
        - Clear navigation structure
        - Interactive examples
        - Code snippets
        - Troubleshooting guide
        """
        
        api_docs = await self.driver.process_query(query)
        return api_docs
    
    async def create_user_manual(self, product_info):
        """Generate comprehensive user manual"""
        
        query = f"""
        Create user manual for product:
        
        Product Information: {product_info}
        
        Generate manual with:
        1. Getting started guide
        2. Feature-by-feature walkthrough
        3. Step-by-step tutorials
        4. Screenshots and visual guides
        5. Common use cases and workflows
        6. Troubleshooting section
        7. FAQ with answers
        8. Advanced tips and tricks
        
        Structure for:
        - Multiple user skill levels
        - Searchable content
        - Progressive disclosure
        - Visual learning support
        """
        
        user_manual = await self.driver.process_query(query)
        return user_manual

# Example usage
async def documentation_example():
    generator = TechnicalDocumentationGenerator()
    await generator.initialize()
    
    # Sample API specifications
    api_specs = {
        'name': 'FACT Analytics API',
        'version': '2.0',
        'base_url': 'https://api.fact-analytics.com/v2',
        'authentication': 'API Key',
        'endpoints': [
            {
                'path': '/analyze',
                'method': 'POST',
                'description': 'Analyze data using FACT templates',
                'parameters': {
                    'data': 'object (required)',
                    'template': 'string (optional)',
                    'options': 'object (optional)'
                }
            },
            {
                'path': '/templates',
                'method': 'GET',
                'description': 'List available analysis templates'
            }
        ],
        'rate_limits': '1000 requests per hour',
        'supported_formats': ['JSON', 'CSV']
    }
    
    # Generate API documentation
    docs = await generator.generate_api_documentation(api_specs)
    print("📚 API Documentation:")
    print(docs)
    
    await generator.driver.close()

asyncio.run(documentation_example())

Platform Integration Examples

Slack Bot Integration

from slack_bolt.async_app import AsyncApp
import asyncio

class FACTSlackBot:
    """FACT-powered Slack bot for team analytics"""
    
    def __init__(self, slack_token, signing_secret):
        self.app = AsyncApp(token=slack_token, signing_secret=signing_secret)
        self.driver = None
        self.setup_handlers()
    
    async def initialize(self):
        self.driver = await get_driver()
    
    def setup_handlers(self):
        @self.app.command("/fact-analyze")
        async def handle_analyze_command(ack, respond, command):
            await ack()
            
            try:
                # Parse user input
                query = command['text']
                user_id = command['user_id']
                
                # Process with FACT
                result = await self.driver.process_query(f"""
                Analyze this request from a team member: {query}
                
                Provide business insights in a conversational, Slack-friendly format:
                - Keep responses concise and actionable
                - Use bullet points for clarity
                - Include relevant metrics or data points
                - Suggest next steps if applicable
                - Format for easy scanning in Slack
                """)
                
                await respond({
                    "response_type": "in_channel",
                    "text": f"📊 Analysis Results",
                    "blocks": [
                        {
                            "type": "section",
                            "text": {
                                "type": "mrkdwn",
                                "text": f"*Analysis for:* {query}\n\n{result}"
                            }
                        },
                        {
                            "type": "context",
                            "elements": [
                                {
                                    "type": "mrkdwn",
                                    "text": f"Requested by <@{user_id}> | Powered by FACT"
                                }
                            ]
                        }
                    ]
                })
                
            except Exception as e:
                await respond(f"❌ Error processing request: {str(e)}")
        
        @self.app.message("fact help")
        async def handle_help_message(message, say):
            help_text = """
🤖 *FACT Analytics Bot Help*

*Available Commands:*
• `/fact-analyze [your question]` - Get AI-powered business analysis
• Type "fact help" - Show this help message
• Type "fact examples" - See example queries

*Example Queries:*
• "Analyze our Q1 sales performance"
• "What are the trends in customer support tickets?"
• "Compare our product performance across regions"
• "Identify opportunities in our user engagement data"

*Tips:*
• Be specific about what data or insights you need
• Include timeframes when relevant
• Ask follow-up questions for deeper analysis
            """
            
            await say(help_text)
    
    async def start(self, port=3000):
        await self.initialize()
        await self.app.async_start(port=port)

# Example usage
async def slack_bot_example():
    # Initialize bot (requires Slack tokens)
    bot = FACTSlackBot(
        slack_token="xoxb-your-token",
        signing_secret="your-signing-secret"
    )
    
    print("🤖 Starting FACT Slack Bot...")
    await bot.start()

# Note: This example shows the structure - actual implementation 
# requires valid Slack credentials and proper deployment

Microsoft Teams Integration

from botbuilder.core import ActivityHandler, TurnContext
from botbuilder.schema import ChannelAccount
import asyncio

class FACTTeamsBot(ActivityHandler):
    """FACT-powered Microsoft Teams bot"""
    
    def __init__(self):
        super().__init__()
        self.driver = None
    
    async def initialize(self):
        self.driver = await get_driver()
    
    async def on_message_activity(self, turn_context: TurnContext):
        user_message = turn_context.activity.text
        
        # Check for FACT commands
        if user_message.lower().startswith('fact '):
            query = user_message[5:]  # Remove 'fact ' prefix
            
            try:
                # Process with FACT
                result = await self.driver.process_query(f"""
                Answer this Teams user's business question: {query}
                
                Provide professional, actionable insights formatted for Microsoft Teams:
                - Use clear, business-appropriate language
                - Structure with headers and bullet points
                - Include relevant metrics
                - Keep responses focused and practical
                - Suggest actionable next steps
                """)
                
                # Format response for Teams
                response = f"📊 **FACT Analysis Results**\n\n{result}"
                
                await turn_context.send_activity(response)
                
            except Exception as e:
                await turn_context.send_activity(f"❌ Analysis error: {str(e)}")
        
        elif user_message.lower() == 'fact help':
            help_text = """
🔍 **FACT Analytics Bot for Teams**

**How to use:**
- Type `fact [your question]` to get AI-powered analysis
- Example: `fact analyze our customer satisfaction trends`

**Sample queries:**
• `fact what are our top performing products?`
• `fact analyze sales trends for Q1`
• `fact identify customer churn patterns`
• `fact review team productivity metrics`

Need specific data analyzed? Just ask!
            """
            await turn_context.send_activity(help_text)

# Example bot setup (requires Teams Bot Framework setup)

Zapier Integration

from flask import Flask, request, jsonify
import asyncio

app = Flask(__name__)

class FACTZapierIntegration:
    """FACT integration for Zapier automation"""
    
    def __init__(self):
        self.driver = None
    
    async def initialize(self):
        self.driver = await get_driver()

# Global instance
fact_zapier = FACTZapierIntegration()

@app.before_first_request
async def setup():
    await fact_zapier.initialize()

@app.route('/zapier/analyze', methods=['POST'])
def zapier_analyze():
    """Zapier trigger for data analysis"""
    try:
        data = request.json
        query = data.get('query', '')
        input_data = data.get('data', {})
        
        # Process with FACT
        loop = asyncio.new_event_loop()
        asyncio.set_event_loop(loop)
        
        analysis_query = f"""
        Analyze this data for a Zapier automation workflow:
        
        User Query: {query}
        Input Data: {input_data}
        
        Provide analysis in structured format suitable for automation:
        - Clear, actionable insights
        - Specific recommendations
        - Numeric results where applicable
        - Status indicators (good/warning/critical)
        - Next action suggestions
        """
        
        result = loop.run_until_complete(
            fact_zapier.driver.process_query(analysis_query)
        )
        
        return jsonify({
            'success': True,
            'analysis': result,
            'input_query': query,
            'processed_at': datetime.now().isoformat()
        })
        
    except Exception as e:
        return jsonify({
            'success': False,
            'error': str(e)
        }), 500

@app.route('/zapier/test', methods=['GET'])
def zapier_test():
    """Test endpoint for Zapier connection"""
    return jsonify({
        'status': 'connected',
        'service': 'FACT Analytics',
        'version': '2.0',
        'timestamp': datetime.now().isoformat()
    })

# Example Zapier webhook setup

These practical examples demonstrate real-world applications of FACT across various industries and use cases. Each example includes complete, working code that can be adapted for specific business needs, with comprehensive error handling and best practices for production deployment.

The examples show how FACT can transform raw data into actionable business insights, automate complex analytical workflows, and integrate seamlessly with existing business tools and processes.

Clone this wiki locally