🤖 Automator Engine¶
Workflow automation engine for business logic and campaign automation
🎯 Overview¶
The Automator Engine is a sophisticated workflow automation system that handles complex business logic, campaign automation, and event-driven processes across the Appgain platform. It provides visual workflow builders, trigger-based automation, and integration with all platform services.
🏗️ Architecture¶
Core Components¶
- Workflow Engine: Executes automation workflows
- Trigger Manager: Handles event-based triggers
- Action Executor: Executes workflow actions
- Condition Evaluator: Evaluates workflow conditions
- Integration Hub: Connects with external services
- Visual Builder: Drag-and-drop workflow designer
Technology Stack¶
- Python: Core automation engine
- Celery: Distributed task processing
- Redis: Workflow state management
- MongoDB: Workflow definitions and data
- Node.js: API layer and integrations
- React: Visual workflow builder
Infrastructure¶
- Server:
ovh-devops(Automator service) - Port: 5000 (HTTP), 5001 (HTTPS)
- Environment: Production, Staging, Development
- Workflows: 1000+ active workflows
🔧 Configuration¶
Server Details¶
- Server:
ovh-devops - Port: 5000 (HTTP), 5001 (HTTPS)
- Base URL:
https://automator.appgain.io - Environment: Production, Staging, Development
Engine Configuration¶
# automator.config.py
AUTOMATOR_CONFIG = {
'workflow_engine': {
'max_concurrent_workflows': 100,
'workflow_timeout': 300, # 5 minutes
'retry_attempts': 3,
'retry_delay': 60 # 1 minute
},
'triggers': {
'user_signup': {
'enabled': True,
'conditions': ['email_verified'],
'actions': ['send_welcome_email', 'create_user_profile']
},
'purchase_completed': {
'enabled': True,
'conditions': ['payment_successful'],
'actions': ['send_receipt', 'update_loyalty_points']
},
'abandoned_cart': {
'enabled': True,
'conditions': ['cart_abandoned_24h'],
'actions': ['send_reminder_email', 'push_notification']
}
},
'integrations': {
'notify_service': {
'url': 'https://notify.appgain.io',
'api_key': 'NOTIFY_API_KEY'
},
'parse_server': {
'url': 'https://parse.appgain.io',
'app_id': 'PARSE_APP_ID',
'master_key': 'PARSE_MASTER_KEY'
},
'email_platform': {
'url': 'https://email.appgain.io',
'smtp_config': 'SMTP_CONFIG'
}
}
}
Workflow Definition¶
{
"workflow_id": "welcome_campaign_001",
"name": "Welcome Campaign",
"description": "Automated welcome campaign for new users",
"trigger": {
"type": "user_signup",
"conditions": [
{
"field": "email_verified",
"operator": "equals",
"value": true
}
]
},
"actions": [
{
"id": "action_001",
"type": "send_email",
"template": "welcome_email",
"delay": 0,
"data": {
"recipient": "{{user.email}}",
"subject": "Welcome to Appgain!",
"variables": {
"user_name": "{{user.name}}",
"signup_date": "{{user.createdAt}}"
}
}
},
{
"id": "action_002",
"type": "send_push",
"template": "welcome_push",
"delay": 300, // 5 minutes delay
"data": {
"recipients": ["{{user.deviceToken}}"],
"title": "Welcome!",
"body": "Thanks for joining Appgain"
}
},
{
"id": "action_003",
"type": "update_user_profile",
"delay": 600, // 10 minutes delay
"data": {
"user_id": "{{user.id}}",
"profile_data": {
"onboarding_completed": true,
"welcome_campaign_sent": true
}
}
}
],
"settings": {
"enabled": true,
"max_executions": 10000,
"timeout": 300
}
}
📊 Workflow Management¶
Trigger Types¶
# Available triggers
TRIGGER_TYPES = {
'user_signup': 'User registration event',
'user_login': 'User login event',
'purchase_completed': 'Purchase completion event',
'abandoned_cart': 'Cart abandonment event',
'app_install': 'App installation event',
'app_uninstall': 'App uninstallation event',
'email_opened': 'Email open event',
'email_clicked': 'Email click event',
'push_opened': 'Push notification open event',
'custom_event': 'Custom business event'
}
Action Types¶
# Available actions
ACTION_TYPES = {
'send_email': 'Send email notification',
'send_sms': 'Send SMS message',
'send_push': 'Send push notification',
'send_whatsapp': 'Send WhatsApp message',
'update_user_profile': 'Update user data',
'create_segment': 'Create user segment',
'add_to_campaign': 'Add user to campaign',
'webhook_call': 'Call external webhook',
'delay': 'Add delay to workflow',
'condition': 'Evaluate condition',
'loop': 'Repeat actions',
'custom_action': 'Custom business action'
}
Condition Types¶
# Available conditions
CONDITION_TYPES = {
'equals': 'Field equals value',
'not_equals': 'Field not equals value',
'contains': 'Field contains value',
'not_contains': 'Field not contains value',
'greater_than': 'Field greater than value',
'less_than': 'Field less than value',
'is_empty': 'Field is empty',
'is_not_empty': 'Field is not empty',
'in_list': 'Field value in list',
'not_in_list': 'Field value not in list'
}
🔍 Monitoring & Analytics¶
Workflow Analytics¶
# Workflow execution metrics
workflow_metrics = {
'total_executions': 15000,
'successful_executions': 14850,
'failed_executions': 150,
'success_rate': 99.0,
'average_execution_time': 2.5, # seconds
'active_workflows': 45,
'total_triggers': 25000
}
Performance Metrics¶
- Execution Rate: 1000+ workflows per hour
- Success Rate: >99% successful executions
- Response Time: <5 seconds average
- Uptime: 99.9% service availability
Real-Time Monitoring¶
# Check workflow status
curl -X GET "https://automator.appgain.io/api/workflows/status" \
-H "Authorization: Bearer YOUR_API_KEY"
# Get execution logs
curl -X GET "https://automator.appgain.io/api/workflows/logs?workflow_id=welcome_campaign_001" \
-H "Authorization: Bearer YOUR_API_KEY"
🔒 Security¶
Access Control¶
- API Authentication: Secure API key authentication
- Workflow Permissions: Role-based workflow access
- Data Encryption: Encrypted workflow data
- Audit Logging: Complete execution audit trail
Data Protection¶
- PII Handling: Secure personal data processing
- GDPR Compliance: Data privacy compliance
- Data Retention: Configurable data retention policies
- Backup & Recovery: Automated backup systems
📈 Performance¶
Capabilities¶
- Concurrent Workflows: 100+ simultaneous executions
- Complex Logic: Multi-step workflow support
- Real-Time Triggers: Instant event processing
- Scalable: Horizontal scaling support
Limitations¶
- Workflow Timeout: 5 minutes maximum execution time
- Action Count: 50 maximum actions per workflow
- Data Size: 10MB maximum workflow data
- Execution Rate: 1000 workflows per hour
🔗 Integration Examples¶
E-commerce Automation¶
{
"workflow_id": "abandoned_cart_recovery",
"name": "Abandoned Cart Recovery",
"trigger": {
"type": "abandoned_cart",
"conditions": [
{
"field": "cart_value",
"operator": "greater_than",
"value": 50
}
]
},
"actions": [
{
"type": "send_email",
"template": "cart_reminder",
"data": {
"recipient": "{{user.email}}",
"subject": "Your cart is waiting!",
"variables": {
"user_name": "{{user.name}}",
"cart_items": "{{cart.items}}",
"cart_total": "{{cart.total}}"
}
}
},
{
"type": "send_push",
"data": {
"recipients": ["{{user.deviceToken}}"],
"title": "Don't forget your cart!",
"body": "Complete your purchase and get 10% off"
}
}
]
}
User Onboarding¶
{
"workflow_id": "user_onboarding",
"name": "User Onboarding Sequence",
"trigger": {
"type": "user_signup"
},
"actions": [
{
"type": "send_email",
"template": "welcome_email",
"delay": 0
},
{
"type": "send_push",
"template": "welcome_push",
"delay": 300
},
{
"type": "send_email",
"template": "getting_started",
"delay": 3600
},
{
"type": "send_email",
"template": "feature_showcase",
"delay": 86400
}
]
}
Customer Retention¶
{
"workflow_id": "customer_retention",
"name": "Customer Retention Campaign",
"trigger": {
"type": "user_inactive",
"conditions": [
{
"field": "days_since_last_activity",
"operator": "greater_than",
"value": 7
}
]
},
"actions": [
{
"type": "send_email",
"template": "we_miss_you",
"data": {
"recipient": "{{user.email}}",
"subject": "We miss you!",
"variables": {
"user_name": "{{user.name}}",
"last_activity": "{{user.lastActivity}}"
}
}
},
{
"type": "send_push",
"data": {
"recipients": ["{{user.deviceToken}}"],
"title": "Come back!",
"body": "We have something special for you"
}
}
]
}
🛠️ Troubleshooting¶
Common Issues¶
Workflow Execution Failures¶
# Check workflow status
curl -X GET "https://automator.appgain.io/api/workflows/status" \
-H "Authorization: Bearer YOUR_API_KEY"
# Check execution logs
curl -X GET "https://automator.appgain.io/api/workflows/logs?workflow_id=workflow_id" \
-H "Authorization: Bearer YOUR_API_KEY"
Trigger Issues¶
# Test trigger manually
curl -X POST "https://automator.appgain.io/api/triggers/test" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"trigger_type": "user_signup",
"user_data": {
"id": "user123",
"email": "test@example.com",
"name": "Test User"
}
}'
Integration Errors¶
# Test integration
curl -X POST "https://automator.appgain.io/api/integrations/test" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"integration": "notify_service",
"action": "send_email",
"data": {
"recipient": "test@example.com",
"subject": "Test",
"body": "Test message"
}
}'
Debug Commands¶
# Check service health
curl -X GET "https://automator.appgain.io/health"
# View service logs
tail -f /var/log/automator/app.log
# Check Redis connection
redis-cli ping
# Check Celery workers
celery -A automator inspect active
📚 Documentation¶
External Resources¶
- Automator API: API Documentation
- Workflow Builder: Visual Builder Guide
- Celery Documentation: Celery Docs
- Redis Documentation: Redis Docs
Monitoring Tools¶
- Grafana Dashboards: Real-time workflow metrics
- Prometheus: Performance monitoring
- ELK Stack: Log analysis and alerting
- Custom Analytics: Workflow success tracking
Development Tools¶
- Postman Collection: API testing and documentation
- GitLab Repository: AppGain Automator
- Development Environment: Docker setup for local testing
- Testing Framework: Automated workflow testing
🔗 Related Resources¶
- System Architecture? → System Architecture
- Notify Service? → Notify Service
- Task Queue? → Task Queue
- Parse Server? → Parse Server
- Learning Resources? → Learning Resources
Ask Chehab GPT