Files
smoothschedule/smoothschedule/AUTOMATION_EXAMPLES.md
poduck 3fef0d5749 feat: Add comprehensive plugin documentation and advanced template system
Added complete plugin documentation with visual mockups and expanded template
variable system with CONTEXT, DATE helpers, and default values.

Backend Changes:
- Extended template_parser.py to support all new template types
- Added PROMPT with default values: {{PROMPT:var|desc|default}}
- Added CONTEXT variables: {{CONTEXT:business_name}}, {{CONTEXT:owner_email}}
- Added DATE helpers: {{DATE:today}}, {{DATE:+7d}}, {{DATE:monday}}
- Implemented date expression evaluation for relative dates
- Updated compile_template to handle all template types
- Added context parameter for business data auto-fill

Frontend Changes:
- Created comprehensive HelpPluginDocs.tsx with Stripe-style API docs
- Added visual mockup of plugin configuration form
- Documented all template types with examples and benefits
- Added Command Reference section with allowed/blocked Python commands
- Documented all HTTP methods (GET, POST, PUT, PATCH, DELETE)
- Added URL whitelisting requirements and approval process
- Created Platform Staff management page with edit modal
- Added can_approve_plugins and can_whitelist_urls permissions

Platform Staff Features:
- List all platform_manager and platform_support users
- Edit user details with role-based permissions
- Superusers can edit anyone
- Platform managers can only edit platform_support users
- Permission cascade: users can only grant permissions they have
- Real-time updates via React Query cache invalidation

Documentation Highlights:
- 4 template types: PROMPT, CONTEXT, DATE, and automatic validation
- Visual form mockup showing exactly what users see
- All allowed control flow (if/elif/else, for, while, try/except, etc.)
- All allowed built-in functions (len, range, min, max, etc.)
- All blocked operations (import, exec, eval, class/function defs)
- Complete HTTP API reference with examples
- URL whitelisting process: contact pluginaccess@smoothschedule.com

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 20:54:07 -05:00

9.6 KiB

Real-World Automation Examples

This document shows practical examples of automations that businesses can create using the scheduler plugin system.

Example 1: Client Re-engagement Campaign

The Problem

A hair salon loses 30% of first-time customers who never return. They need to automatically win them back.

The Solution

Automated email campaign that targets inactive customers with personalized offers.

Setup

# Create the scheduled task
curl -X POST http://lvh.me:8000/api/scheduled-tasks/ \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Weekly Client Re-engagement",
    "description": "Reach out to customers who haven'\''t booked in 60 days",
    "plugin_name": "client_reengagement",
    "plugin_config": {
      "days_inactive": 60,
      "email_subject": "We Miss You at Bella Hair Salon!",
      "discount_percentage": 20,
      "promo_code_prefix": "COMEBACK",
      "max_customers_per_run": 50,
      "minimum_past_visits": 1
    },
    "schedule_type": "CRON",
    "cron_expression": "0 10 * * 1",
    "status": "ACTIVE"
  }'

Schedule: Every Monday at 10 AM

What It Does

  1. Finds Inactive Customers

    • Looks for customers who haven't booked in 60 days
    • Must have at least 1 previous visit
    • Limits to 50 customers per week to avoid spam
  2. Sends Personalized Emails

    Subject: We Miss You at Bella Hair Salon!
    
    Hi Sarah,
    
    We noticed it's been a while since your last visit on March 15, 2024.
    We'd love to see you again!
    
    As a valued customer, we're offering you 20% off your next appointment.
    
    Book now and use code: COMEBACK123
    
    Looking forward to seeing you soon!
    Bella Hair Salon
    
  3. Tracks Results

    • Logs every customer contacted
    • Records promo codes generated
    • Measures campaign effectiveness

Expected Results

  • Recovery Rate: 15-20% of contacted customers return
  • Revenue Impact: $3,000-5,000/month in recovered bookings
  • ROI: 10x (automated vs manual outreach)

Example 2: No-Show Rate Alert System

The Problem

A dental office notices appointments are being canceled at the last minute, but they don't realize how bad it is until it's too late.

The Solution

Automated monitoring that alerts when no-show rates spike.

Setup

curl -X POST http://lvh.me:8000/api/scheduled-tasks/ \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Daily No-Show Monitoring",
    "description": "Alert if no-show rate exceeds 20%",
    "plugin_name": "low_show_rate_alert",
    "plugin_config": {
      "threshold_percentage": 20,
      "lookback_days": 7,
      "alert_emails": ["manager@dentalclinic.com", "owner@dentalclinic.com"],
      "min_appointments": 10
    },
    "schedule_type": "CRON",
    "cron_expression": "0 8 * * *",
    "status": "ACTIVE"
  }'

Schedule: Every day at 8 AM

What It Does

  1. Analyzes Past 7 Days

    • Counts total appointments
    • Counts cancellations/no-shows
    • Calculates no-show rate
  2. Sends Alerts When Needed

    Subject: ⚠️ High No-Show Rate Alert - Downtown Dental
    
    Alert: Your no-show rate is unusually high!
    
    No-Show Rate: 23.5%
    Period: Last 7 days
    Canceled Appointments: 12 out of 51
    
    Recommended Actions:
    1. Review your confirmation process
    2. Send appointment reminders 24 hours before
    3. Implement a cancellation policy
    4. Follow up with customers who no-showed
    
  3. Only Alerts on Real Issues

    • Requires minimum 10 appointments before alerting
    • Prevents false alarms on slow weeks

Expected Results

  • Early Detection: Spot issues within 1 week instead of 1 month
  • Reduced No-Shows: 23% → 12% after implementing recommendations
  • Revenue Saved: $2,000+/month in prevented lost appointments

Example 3: Peak Hours Staffing Optimizer

The Problem

A massage spa isn't sure when to schedule their therapists. They're overstaffed on slow days and understaffed during peak hours.

The Solution

Monthly analysis of booking patterns with staffing recommendations.

Setup

curl -X POST http://lvh.me:8000/api/scheduled-tasks/ \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Monthly Peak Hours Analysis",
    "description": "Analyze booking patterns for better staffing",
    "plugin_name": "peak_hours_analyzer",
    "plugin_config": {
      "analysis_days": 30,
      "report_emails": ["scheduler@zenmasssage.com"],
      "group_by": "both"
    },
    "schedule_type": "CRON",
    "cron_expression": "0 9 1 * *",
    "status": "ACTIVE"
  }'

Schedule: First day of every month at 9 AM

What It Does

  1. Analyzes 30 Days of Data

    • Groups appointments by hour of day
    • Groups appointments by day of week
    • Identifies patterns
  2. Generates Report

    Peak Hours Analysis Report
    Business: Zen Massage Spa
    Period: Last 30 days
    Total Appointments: 284
    
    TOP 5 BUSIEST HOURS:
      17:00 - 18:00: 45 appointments (15.8%)
      18:00 - 19:00: 42 appointments (14.8%)
      14:00 - 15:00: 38 appointments (13.4%)
      15:00 - 16:00: 35 appointments (12.3%)
      16:00 - 17:00: 32 appointments (11.3%)
    
    TOP 3 BUSIEST DAYS:
      Saturday: 68 appointments (23.9%)
      Friday: 52 appointments (18.3%)
      Thursday: 44 appointments (15.5%)
    
    RECOMMENDATIONS:
    • Ensure adequate staffing during peak hours (5-7 PM)
    • Consider offering promotions during slower periods (mornings)
    • Schedule 3-4 therapists on Saturdays
    • Review this analysis monthly to spot trends
    
  3. Provides Actionable Insights

    • Clear staffing recommendations
    • Revenue optimization opportunities
    • Trend tracking over time

Expected Results

  • Optimized Staffing: Better therapist utilization
  • Reduced Labor Costs: 15% savings from better scheduling
  • Increased Revenue: 10% more bookings during promoted off-peak hours
  • Staff Satisfaction: More predictable schedules

Example 4: Combo Campaign (Advanced)

The Problem

A boutique fitness studio wants a complete automation system that handles multiple aspects of their business.

The Solution

Multiple scheduled tasks working together.

Setup

Task 1: Daily Client Re-engagement (Runs Monday/Wednesday/Friday)

{
  "name": "Client Winback - MWF",
  "plugin_name": "client_reengagement",
  "schedule_type": "CRON",
  "cron_expression": "0 9 * * 1,3,5",
  "plugin_config": {
    "days_inactive": 45,
    "discount_percentage": 25,
    "max_customers_per_run": 20
  }
}

Task 2: Weekly Performance Report (Runs Sunday evening)

{
  "name": "Weekly Studio Report",
  "plugin_name": "daily_report",
  "schedule_type": "CRON",
  "cron_expression": "0 20 * * 0",
  "plugin_config": {
    "recipients": ["owner@fitstudio.com"],
    "include_upcoming": true,
    "include_completed": true
  }
}

Task 3: No-Show Monitoring (Runs daily)

{
  "name": "No-Show Monitor",
  "plugin_name": "low_show_rate_alert",
  "schedule_type": "CRON",
  "cron_expression": "0 7 * * *",
  "plugin_config": {
    "threshold_percentage": 15,
    "lookback_days": 7,
    "alert_emails": ["manager@fitstudio.com"]
  }
}

Task 4: Monthly Analytics (Runs first Monday of month)

{
  "name": "Monthly Analytics",
  "plugin_name": "peak_hours_analyzer",
  "schedule_type": "CRON",
  "cron_expression": "0 9 1 * *",
  "plugin_config": {
    "analysis_days": 30,
    "report_emails": ["owner@fitstudio.com", "manager@fitstudio.com"]
  }
}

Task 5: Database Cleanup (Runs weekly)

{
  "name": "Weekly Cleanup",
  "plugin_name": "cleanup_old_events",
  "schedule_type": "CRON",
  "cron_expression": "0 2 * * 0",
  "plugin_config": {
    "days_old": 180,
    "statuses": ["CANCELED"],
    "dry_run": false
  }
}

Combined Impact

  • 40+ hours/month of manual work automated
  • 20-30% increase in customer retention
  • 15% reduction in no-shows
  • $5,000+/month in recovered revenue
  • Complete visibility into business performance

Business Value Summary

Automation Time Saved Revenue Impact Setup Time
Client Re-engagement 10 hrs/month +$3,000-5,000/month 10 minutes
No-Show Alerts 5 hrs/month +$2,000/month 5 minutes
Peak Hours Analysis 8 hrs/month +$1,500/month 5 minutes
Combined System 40+ hrs/month +$8,000+/month 30 minutes

Why This System is Powerful

For Business Owners

  • Set and Forget: Configure once, runs forever
  • No Technical Skills: Simple JSON configuration
  • Measurable ROI: Track exactly what each automation does
  • Risk-Free: Can be paused/modified/deleted anytime

For the Platform

  • High Value: Businesses will pay premium for this
  • Sticky: Once automated, they won't want to leave
  • Scalable: Same plugins work for any business type
  • Upsell Opportunity: "Automation Package" pricing tier

For Customers

  • Better Service: More timely communications
  • More Convenient: Reminders and promotions when needed
  • Personalized: Targeted, relevant messages

Next Steps

  1. Add More Plugins:

    • Birthday/anniversary campaigns
    • Review request automation
    • Social media posting
    • Inventory alerts
    • Revenue forecasting
  2. Create Templates:

    • Industry-specific automation bundles
    • "Starter Pack" for new businesses
    • "Growth Pack" for scaling businesses
  3. Add UI:

    • Visual workflow builder
    • Analytics dashboard
    • A/B testing for campaigns
  4. Monetization:

    • Free: 3 active automations
    • Pro ($29/mo): 10 active automations
    • Business ($99/mo): Unlimited + custom plugins