AI & Estimating
ServiceFlow AI Integration Guide
Setup and testing guide for AI pricing and product recommendations with real business data.
12 min readServiceFlow 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
- Navigate to
/ai-demoin your web app - Try different business types (HVAC, Plumbing, Electrical)
- Test various locations and service types
- 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
- Check server logs for detailed error messages
- Verify database connections and data existence
- Test API endpoints individually
- Check environment variables are loaded
- 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! ๐โจ