Kubiya LogoKubiya Developer Docs

Examples & Use Cases

Real-world examples of automatic task composition for DevOps, security, and business automation

Examples & Use Cases

Explore real-world examples of how automatic task composition works across different domains. These examples show the natural language inputs and the sophisticated workflows that the Agent Composer generates automatically.

DevOps Automation

Example 1: Complete Application Deployment

Natural Language Input

"Deploy my React application to production with the following requirements:
- Build and test the application first
- Run security scans on dependencies  
- Deploy to Kubernetes with zero downtime
- Verify the deployment health
- Send notifications to the #devops channel
- Rollback automatically if anything fails"

Generated Workflow

The system automatically creates this comprehensive deployment workflow:

{
  "name": "react-production-deployment",
  "description": "Complete React application deployment with security and verification",
  "domain": "devops",
  "complexity": "high",
  "agents": {
    "build_agent": {
      "tools": ["node_build", "npm_test", "docker_build"],
      "runner": "build-runner"
    },
    "security_agent": {
      "tools": ["npm_audit", "dependency_check", "vulnerability_scan"],
      "runner": "security-runner"
    },
    "deployment_agent": {
      "tools": ["kubectl", "helm", "health_check"],
      "runner": "k8s-runner"
    },
    "notification_agent": {
      "tools": ["slack_notify"],
      "runner": "notification-runner"
    }
  },
  "steps": [
    {
      "name": "build_and_test",
      "agent": "build_agent",
      "description": "Build React app and run tests",
      "executor": {
        "type": "tool",
        "config": {
          "tool_def": {
            "name": "react-build-pipeline",
            "type": "docker",
            "image": "node:18-alpine",
            "content": "npm ci && npm run build && npm test"
          }
        }
      },
      "output": "BUILD_RESULT"
    },
    {
      "name": "security_scan",
      "agent": "security_agent", 
      "description": "Run comprehensive security analysis",
      "depends_on": ["build_and_test"],
      "parallel": true,
      "approval_required": false
    },
    {
      "name": "deploy_to_k8s",
      "agent": "deployment_agent",
      "description": "Deploy to Kubernetes with rolling update",
      "depends_on": ["security_scan"],
      "approval_required": true,
      "approval_message": "⚠️ Deploy to production?",
      "rollback_on_failure": true
    },
    {
      "name": "health_verification",
      "agent": "deployment_agent",
      "description": "Verify deployment health and readiness",
      "depends_on": ["deploy_to_k8s"],
      "timeout": "300s"
    },
    {
      "name": "notify_team",
      "agent": "notification_agent",
      "description": "Send deployment status to team",
      "depends_on": ["health_verification"],
      "context": {
        "channel": "#devops",
        "message_template": "✅ {{app_name}} v{{version}} deployed successfully"
      }
    }
  ],
  "error_handling": {
    "global_rollback": true,
    "notification_on_failure": true,
    "max_retries": 2
  }
}

Context Automatically Resolved

secrets:
  - "@secrets/github-token"          # For repository access
  - "@secrets/docker-registry"       # For image push/pull
  - "@secrets/k8s-config"           # Kubernetes cluster access
  - "@secrets/slack-webhook"        # Team notifications
 
knowledge:
  - "@knowledge/deployment-runbooks" # Best practices
  - "@knowledge/rollback-procedures" # Failure recovery
 
custom:
  app_name: "my-react-app"
  version: "latest"
  environment: "production"
  deployment_strategy: "rolling"

Example 2: Infrastructure Health Check

Natural Language Input

"Check the health of my entire Kubernetes cluster and alert me if anything is wrong"

Generated Workflow

A simple but comprehensive health monitoring workflow:

{
  "name": "cluster-health-check",
  "description": "Comprehensive Kubernetes cluster health assessment",
  "domain": "infrastructure",
  "complexity": "medium",
  "agents": {
    "k8s_monitoring_agent": {
      "tools": ["kubectl", "cluster_analyzer", "resource_monitor"],
      "runner": "monitoring-runner"
    }
  },
  "steps": [
    {
      "name": "cluster_overview",
      "description": "Get cluster status and node health",
      "executor": {
        "type": "tool",
        "config": {
          "tool_def": {
            "content": "kubectl get nodes && kubectl top nodes && kubectl get pods --all-namespaces | grep -v Running"
          }
        }
      }
    },
    {
      "name": "resource_analysis", 
      "description": "Analyze resource usage and capacity",
      "depends_on": ["cluster_overview"]
    },
    {
      "name": "alert_if_issues",
      "description": "Send alerts for any detected issues",
      "depends_on": ["resource_analysis"],
      "conditional": "issues_detected == true"
    }
  ]
}

Security Operations

Example 3: Security Incident Response

Natural Language Input

"We have a security alert for suspicious activity. Investigate the affected systems, 
isolate any compromised resources, and generate a complete incident report"

Generated Workflow

An automated incident response workflow:

{
  "name": "security-incident-response",
  "description": "Automated security incident investigation and response",
  "domain": "security",
  "complexity": "high",
  "agents": {
    "investigation_agent": {
      "tools": ["log_analyzer", "network_scanner", "forensics_tool"],
      "runner": "security-runner"
    },
    "isolation_agent": {
      "tools": ["firewall_manager", "access_control", "quarantine"],
      "runner": "security-runner"
    },
    "reporting_agent": {
      "tools": ["report_generator", "evidence_collector"],
      "runner": "compliance-runner"
    }
  },
  "steps": [
    {
      "name": "initial_investigation",
      "agent": "investigation_agent",
      "description": "Analyze logs and identify scope of incident",
      "priority": "critical",
      "timeout": "600s"
    },
    {
      "name": "threat_assessment",
      "agent": "investigation_agent", 
      "description": "Assess threat level and impact",
      "depends_on": ["initial_investigation"]
    },
    {
      "name": "isolate_affected_systems",
      "agent": "isolation_agent",
      "description": "Isolate compromised or suspicious systems",
      "depends_on": ["threat_assessment"],
      "approval_required": true,
      "approval_message": "🚨 Isolate affected systems?"
    },
    {
      "name": "evidence_collection",
      "agent": "reporting_agent",
      "description": "Collect and preserve digital evidence",
      "depends_on": ["isolate_affected_systems"],
      "parallel": true
    },
    {
      "name": "generate_incident_report",
      "agent": "reporting_agent",
      "description": "Generate comprehensive incident report",
      "depends_on": ["evidence_collection"]
    }
  ]
}

Example 4: Regular Security Audit

Natural Language Input

"Run a weekly security audit of all our AWS resources and send the report to the security team"

Generated Workflow (Scheduled)

{
  "name": "weekly-aws-security-audit",
  "description": "Automated weekly security audit for AWS infrastructure",
  "domain": "security", 
  "complexity": "medium",
  "execution_mode": "scheduled",
  "schedule": {
    "recurring": "weekly",
    "day": "sunday",
    "time": "02:00",
    "timezone": "UTC"
  },
  "agents": {
    "aws_security_agent": {
      "tools": ["aws_config", "security_hub", "guardduty", "inspector"],
      "runner": "aws-runner"
    }
  },
  "steps": [
    {
      "name": "scan_iam_policies",
      "description": "Audit IAM policies and permissions"
    },
    {
      "name": "check_security_groups", 
      "description": "Validate security group configurations"
    },
    {
      "name": "verify_encryption",
      "description": "Ensure all resources are properly encrypted"
    },
    {
      "name": "compliance_check",
      "description": "Run compliance validation against security standards"
    },
    {
      "name": "generate_security_report",
      "description": "Compile comprehensive security report",
      "depends_on": ["scan_iam_policies", "check_security_groups", "verify_encryption", "compliance_check"]
    }
  ]
}

Business Process Automation

Example 5: Customer Onboarding Workflow

Natural Language Input

"When a new customer signs up, create their accounts across all systems, 
set up their initial configuration, send welcome emails, and notify the sales team"

Generated Workflow (Webhook-Triggered)

{
  "name": "customer-onboarding-automation",
  "description": "Complete customer onboarding across all systems",
  "domain": "business_process",
  "complexity": "high",
  "execution_mode": "webhook",
  "webhook": {
    "enabled": true,
    "template": "Onboard new customer {{data.customer.name}} ({{data.customer.email}})",
    "validation": {
      "required_fields": ["data.customer.email", "data.customer.name", "data.plan"],
      "data_types": {
        "data.customer.email": "email",
        "data.plan": "enum:basic,pro,enterprise"
      }
    }
  },
  "agents": {
    "account_provisioning_agent": {
      "tools": ["user_manager", "database_setup", "permission_manager"],
      "runner": "business-runner"
    },
    "notification_agent": {
      "tools": ["email_sender", "slack_notify", "crm_updater"],
      "runner": "communication-runner"
    }
  },
  "steps": [
    {
      "name": "create_user_accounts",
      "agent": "account_provisioning_agent",
      "description": "Create user accounts in all systems",
      "context": {
        "customer_email": "{{webhook.data.customer.email}}",
        "customer_name": "{{webhook.data.customer.name}}",
        "plan_type": "{{webhook.data.plan}}"
      }
    },
    {
      "name": "setup_initial_config",
      "agent": "account_provisioning_agent",
      "description": "Configure initial settings based on plan",
      "depends_on": ["create_user_accounts"]
    },
    {
      "name": "send_welcome_email",
      "agent": "notification_agent",
      "description": "Send personalized welcome email",
      "depends_on": ["setup_initial_config"],
      "parallel": true
    },
    {
      "name": "notify_sales_team",
      "agent": "notification_agent",
      "description": "Notify sales team of new customer",
      "depends_on": ["setup_initial_config"],
      "parallel": true
    }
  ]
}

Data & Analytics

Example 6: Daily Data Pipeline

Natural Language Input

"Every day at 3 AM, extract data from our production database, 
clean and transform it, load it into our data warehouse, 
and generate a summary report for the business team"

Generated Workflow (Scheduled)

{
  "name": "daily-etl-pipeline",
  "description": "Daily ETL pipeline with data processing and reporting",
  "domain": "data_processing",
  "complexity": "high",
  "execution_mode": "scheduled",
  "schedule": {
    "recurring": "daily",
    "time": "03:00",
    "timezone": "UTC"
  },
  "agents": {
    "data_extraction_agent": {
      "tools": ["postgres_connector", "data_extractor"],
      "runner": "data-runner"
    },
    "data_transformation_agent": {
      "tools": ["pandas_processor", "data_cleaner", "validator"],
      "runner": "processing-runner"
    },
    "data_warehouse_agent": {
      "tools": ["snowflake_loader", "table_manager"],
      "runner": "warehouse-runner"
    },
    "reporting_agent": {
      "tools": ["report_generator", "email_sender"],
      "runner": "reporting-runner"
    }
  },
  "steps": [
    {
      "name": "extract_production_data",
      "agent": "data_extraction_agent",
      "description": "Extract data from production database",
      "timeout": "1800s"
    },
    {
      "name": "clean_and_transform",
      "agent": "data_transformation_agent",
      "description": "Clean, validate, and transform extracted data",
      "depends_on": ["extract_production_data"]
    },
    {
      "name": "load_to_warehouse",
      "agent": "data_warehouse_agent",
      "description": "Load transformed data into data warehouse",
      "depends_on": ["clean_and_transform"]
    },
    {
      "name": "generate_business_report",
      "agent": "reporting_agent",
      "description": "Generate daily business summary report",
      "depends_on": ["load_to_warehouse"]
    }
  ]
}

Integration Patterns

CI/CD Pipeline Integration

GitHub Actions Integration

# .github/workflows/deploy.yml
name: Deploy with Kubiya
on:
  push:
    branches: [main]
 
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Trigger Kubiya Deployment
        run: |
          curl -X POST ${{ secrets.KUBIYA_WEBHOOK_URL }} \
            -H "Content-Type: application/json" \
            -d '{
              "event": "deployment_requested",
              "data": {
                "repository": "${{ github.repository }}",
                "branch": "${{ github.ref_name }}",
                "commit": "${{ github.sha }}",
                "environment": "production",
                "version": "${{ github.sha }}"
              }
            }'

Monitoring Integration

Prometheus AlertManager Integration

# alertmanager.yml
route:
  routes:
    - match:
        severity: critical
      webhook_configs:
        - url: 'https://compose.kubiya.ai/api/webhooks/tasks/alert-response-task/secret123'
          send_resolved: true

Slack Integration

Slash Command Trigger

// Slack app configuration
{
  "slash_command": "/deploy",
  "webhook_url": "https://compose.kubiya.ai/api/webhooks/tasks/deploy-task/secret456",
  "payload_template": {
    "event": "slack_deploy_command",
    "data": {
      "user": "{{user_name}}",
      "channel": "{{channel_name}}",
      "command": "{{text}}"
    }
  }
}

Common Patterns

Error Handling Pattern

Every automatically composed workflow includes sophisticated error handling:

{
  "error_handling": {
    "global_retry": {
      "max_attempts": 3,
      "backoff_strategy": "exponential",
      "initial_delay": "30s"
    },
    "step_level_fallbacks": {
      "deployment_step": {
        "fallback_action": "rollback_to_previous",
        "notification": "immediate"
      }
    },
    "circuit_breaker": {
      "failure_threshold": 5,
      "recovery_timeout": "300s"
    }
  }
}

Approval Gate Pattern

For sensitive operations, automatic approval gates are inserted:

{
  "approval_gates": [
    {
      "step": "deploy_to_production",
      "required": true,
      "approvers": ["devops-team", "security-team"],
      "timeout": "1800s",
      "escalation": "manager-approval"
    }
  ]
}

Parallel Execution Pattern

When possible, the system optimizes workflows with parallel execution:

{
  "parallel_groups": [
    {
      "name": "preparation_phase",
      "steps": ["security_scan", "build_assets", "run_tests"],
      "wait_for": "all",
      "continue_on_failure": false
    }
  ]
}

Tips for Effective Natural Language Inputs

🎯 Be Specific About Requirements

Instead of: "Deploy my app"
Try: "Deploy my Node.js app to production with health checks and rollback"

🔄 Include Error Handling Preferences

Instead of: "Run database backup"
Try: "Run database backup and verify integrity, retry 3 times if it fails"

📊 Specify Notifications and Reporting

Instead of: "Process daily data"
Try: "Process daily data and send summary report to data-team@company.com"

Mention Execution Preferences

Instead of: "Check system health"
Try: "Check system health every hour and alert immediately if issues found"

Progressive Enhancement: Start with simple descriptions and gradually add more requirements. The system learns from your patterns and becomes better at predicting what you need.

Best Practices

🚀 Start Simple, Scale Up

  1. Begin with basic single-step operations
  2. Add complexity as you become comfortable
  3. Use the generated workflows as templates for similar tasks
  4. Refine your natural language patterns over time

🔒 Security First

  1. Always specify approval requirements for production operations
  2. Use secrets management for sensitive data
  3. Include audit logging requirements in your descriptions
  4. Specify rollback procedures for risky operations

📈 Monitor and Optimize

  1. Review generated workflows before first execution
  2. Monitor execution metrics and success rates
  3. Refine natural language inputs based on results
  4. Share successful patterns with your team

These examples demonstrate the power of automatic task composition - from simple natural language descriptions to sophisticated, production-ready workflows that handle complex business requirements with proper error handling, security, and monitoring built-in.