Garage Door OS Docs
AI & Estimating

ServiceFlow AI Integration Guide

Setup and testing guide for AI pricing and product recommendations with real business data.
12 min read

ServiceFlow Pro AI Integration Guide

๐ŸŽฏ Complete Integration with Your Real Data

Your AI pricing and product recommender is now fully integrated with ServiceFlow Pro's real business data, inventory, pricing, and customer information.

๐Ÿš€ What's Been Integrated

1. Real Business Data โœ…

  • Business Profiles: Company name, location, currency, settings
  • Business Statistics: Customer counts, job history, revenue data
  • Service Areas: Geographic coverage and performance metrics
  • Pricing Rules: Custom markup, location adjustments, customer discounts

2. Real Customer Data โœ…

  • Customer Insights: Job history, preferences, ratings
  • Location Analysis: City/state performance, customer density
  • Customer Types: Residential vs commercial patterns
  • Service Preferences: Most requested services by area

3. Real Inventory & Pricing โœ…

  • Price Book Items: Your actual services and materials
  • Real-time Availability: Stock levels, lead times, suppliers
  • Dynamic Pricing: Location, urgency, customer type adjustments
  • Business Rules: Your custom pricing logic and discounts

4. OpenAI Integration โœ…

  • API Key: Configured with your OpenAI key
  • GPT-4 Model: Advanced AI reasoning and recommendations
  • Custom Prompts: Business-specific AI instructions
  • Confidence Scoring: AI-powered recommendation quality

๐Ÿ”ง Setup Requirements

Environment Variables

# AI Configuration
OPENAI_API_KEY="YOUR_OPENAI_API_KEY"
AI_PROVIDER="openai"
AI_MODEL="gpt-4"
AI_MAX_TOKENS="2000"
AI_TEMPERATURE="0.7"

# Demo Mode (for testing)
DEMO_MODE="true"

Database Requirements

Your database must have:
  • Business records with location and settings
  • Customer data with types and locations
  • Job history with categories and ratings
  • Price book items with categories and pricing
  • Service definitions with categories

๐Ÿงช Testing the Integration

1. Run the Integration Test

node test-integration.js
This will test:
  • โœ… Business profile integration
  • โœ… AI recommendations with real data
  • โœ… Dynamic pricing with business rules
  • โœ… Real-time data integration
  • โœ… Multiple business scenarios

2. Test in the Web App

  1. Navigate to /ai-demo in your web app
  2. Try different business types (HVAC, Plumbing, Electrical)
  3. Test various locations and service types
  4. Verify recommendations use real business data

3. Check API Endpoints

# Test basic connectivity
curl http://localhost:3001/api/ai/test

# Test AI recommendations
curl -X POST http://localhost:3001/api/ai/recommendations \
  -H "Content-Type: application/json" \
  -H "x-demo-mode: true" \
  -H "x-business-id: demo-business" \
  -d '{
    "jobContext": {
      "serviceType": "HVAC Repair",
      "location": {"city": "Austin", "state": "TX"},
      "customerType": "residential",
      "urgency": "urgent"
    }
  }'

๐Ÿ“Š Data Integration Points

Business Profile Service

  • Location-based pricing: Adjusts prices based on service area
  • Customer type discounts: Residential vs commercial pricing
  • Urgency multipliers: Emergency vs scheduled service pricing
  • Bulk discounts: Multi-item order savings

Customer Insights Engine

  • Job history analysis: Previous service patterns
  • Location performance: Success rates by area
  • Customer preferences: Most popular services
  • Rating analysis: Quality metrics by service type

Inventory Integration

  • Real-time stock levels: Current availability
  • Lead time calculations: Supplier delivery estimates
  • Alternative recommendations: When items are out of stock
  • Business-specific suppliers: Your vendor relationships

๐ŸŽจ Customization Options

Business Settings

{
  "defaultMarkup": 30,
  "locationAdjustments": {
    "Austin": 0.05,
    "Dallas": 0.08
  },
  "customerTypeDiscounts": {
    "residential": 0.05,
    "commercial": 0.10
  },
  "urgencyMultipliers": {
    "low": 1.0,
    "medium": 1.1,
    "high": 1.25,
    "urgent": 1.5
  }
}

AI Prompt Customization

  • Business-specific instructions: Your company policies
  • Service type expertise: HVAC, plumbing, electrical knowledge
  • Quality standards: Your service guarantees
  • Customer service focus: Your business values

๐Ÿ” Troubleshooting

Common Issues

1. No Recommendations Generated

  • Check if you have price book items in your database
  • Verify business ID exists and has data
  • Check OpenAI API key configuration

2. Pricing Calculations Wrong

  • Verify business pricing rules in settings
  • Check location data for jobs and customers
  • Ensure customer types are properly set

3. AI Responses Poor Quality

  • Check OpenAI API quota and limits
  • Verify AI model configuration
  • Review prompt customization

Debug Steps

  1. Check server logs for detailed error messages
  2. Verify database connections and data existence
  3. Test API endpoints individually
  4. Check environment variables are loaded
  5. Verify business data exists in database

๐Ÿš€ Production Deployment

1. Remove Demo Mode

DEMO_MODE="false"

2. Secure API Endpoints

  • Implement proper authentication
  • Add rate limiting
  • Monitor API usage

3. Performance Optimization

  • Cache business profile data
  • Optimize database queries
  • Monitor AI response times

4. Monitoring & Analytics

  • Track recommendation accuracy
  • Monitor pricing effectiveness
  • Analyze customer satisfaction

๐Ÿ“ˆ Business Impact

Immediate Benefits

  • Faster Quotes: AI generates recommendations in seconds
  • Better Pricing: Dynamic adjustments based on real data
  • Improved Accuracy: Data-driven recommendations
  • Professional Appearance: AI-powered sales tool

Long-term Value

  • Customer Satisfaction: Better service recommendations
  • Revenue Growth: Optimized pricing strategies
  • Operational Efficiency: Automated quote generation
  • Competitive Advantage: AI-powered service delivery

๐ŸŽฏ Next Steps

1. Test with Real Data

  • Use actual business IDs from your database
  • Test with real customer scenarios
  • Verify pricing accuracy

2. Customize for Your Business

  • Adjust AI prompts for your services
  • Configure business-specific pricing rules
  • Set up location-based adjustments

3. Train Your Team

  • Show technicians how to use AI recommendations
  • Train sales team on AI-powered quotes
  • Monitor and optimize AI performance

4. Scale and Expand

  • Add more service types and categories
  • Integrate with additional business systems
  • Expand to mobile and field applications

๐ŸŽ‰ You're Ready!

Your AI service is now fully integrated with ServiceFlow Pro! You have:
  • โœ… Real business data integration
  • โœ… OpenAI-powered recommendations
  • โœ… Dynamic pricing engine
  • โœ… Professional error handling
  • โœ… Comprehensive testing tools
Start testing with your real data and watch the AI transform your service delivery! ๐Ÿš€โœจ