Task Functions
Automate scheduled operations and background tasks. Run reports, sync data, send notifications, and perform maintenance on custom schedules without user interaction.
Task functions run on schedules or delays, not in response to user requests. They’re perfect for background work like sending emails, generating reports, data cleanup, and workflow automation.
When to Use
- Daily/weekly reports and analytics
- Scheduled email campaigns and notifications
- Data cleanup and maintenance tasks
- Background data processing and syncing
What They Do
- Run on fixed schedules (cron-like)
- Execute delayed tasks after events
- Process queued work items
- Maintain system health and data integrity
How Task Functions Work
- Schedule triggers at specified intervals (cron expressions or rate limits)
- Task function executes without user interaction
- Background work runs (emails, reports, cleanup, data processing)
- Task completes and returns execution summary
Task Function Examples
Send emails to users who left items in their cart:
Schedule Trigger:
🚀 See Hub Enhancements
🚀 See Hub Enhancements
What Ollie Hub adds:
- ✅ Intelligent cart discovery with time-based filtering
- ✅ Personalized email content with user data
- ✅ Duplicate email prevention system
- ✅ Revenue impact tracking and analytics
- ✅ Performance metrics and optimization data
- ✅ Detailed error handling and reporting
- ✅ Multi-stage recovery email campaigns
Send emails to users who left items in their cart:
Schedule Trigger:
🚀 See Hub Enhancements
🚀 See Hub Enhancements
What Ollie Hub adds:
- ✅ Intelligent cart discovery with time-based filtering
- ✅ Personalized email content with user data
- ✅ Duplicate email prevention system
- ✅ Revenue impact tracking and analytics
- ✅ Performance metrics and optimization data
- ✅ Detailed error handling and reporting
- ✅ Multi-stage recovery email campaigns
Generate and email daily sales reports:
Schedule Trigger:
🚀 See Hub Enhancements
🚀 See Hub Enhancements
What Ollie Hub adds:
- ✅ Comprehensive revenue and customer metrics
- ✅ Top-performing products analysis
- ✅ Customer acquisition and retention insights
- ✅ Day-over-day growth comparisons
- ✅ PDF attachment with charts and graphs
- ✅ Historical data storage and trends
- ✅ Executive dashboard integration
Clean up expired sessions and temporary data:
Schedule Trigger:
🚀 See Hub Enhancements
🚀 See Hub Enhancements
What Ollie Hub adds:
- ✅ Intelligent expired session detection and removal
- ✅ Temporary file cleanup with size optimization
- ✅ Log archival and rotation management
- ✅ Failed upload cleanup and recovery
- ✅ Storage space optimization tracking
- ✅ System health metrics and performance impact
- ✅ Database query performance improvements
Send personalized weekly newsletters to subscribers:
Schedule Trigger:
🚀 See Hub Enhancements
🚀 See Hub Enhancements
What Ollie Hub adds:
- ✅ Batch processing for scalability and deliverability
- ✅ Personalized content based on subscriber preferences
- ✅ Unsubscribe link management and tracking
- ✅ Campaign performance metrics and analytics
- ✅ Error handling with detailed reporting
- ✅ Rate limiting to prevent spam flags
- ✅ Engagement prediction and optimization
Best Practices
Keep Tasks Idempotent
Design tasks to handle being run multiple times safely. Check for existing work before processing.
Process in Batches
For large datasets, process items in small batches to avoid timeouts and memory issues.
Monitor and Alert
Set up monitoring for task failures and send notifications when critical tasks fail.
Handle Failures Gracefully
Implement retry logic with exponential backoff. Store failed items for manual review.
Next Steps
Best Practices
Task patterns, error handling, and scheduling tips
Request Functions
Learn to handle user requests and API calls
Response Functions
Customize responses with analytics and enhancements
Pro Tip: Task functions can trigger Request functions to process data, and Response functions can enhance the results. They work great together! Check out our Best Practices guide for implementation patterns.