{
  "name": "Customer Support Ticket Triage",
  "version": "1.0.0",
  "description": "AI-powered customer support ticket classification, priority assignment, and routing to appropriate teams",
  "input_schema": {
    "type": "object",
    "properties": {
      "ticket_id": {
        "type": "string",
        "description": "Unique ticket identifier"
      },
      "subject": {
        "type": "string",
        "description": "Ticket subject line"
      },
      "message": {
        "type": "string",
        "description": "Customer's message/complaint"
      },
      "customer_email": {
        "type": "string",
        "description": "Customer's email address"
      },
      "customer_tier": {
        "type": "string",
        "enum": ["free", "pro", "enterprise"],
        "default": "free"
      }
    },
    "required": ["ticket_id", "subject", "message", "customer_email"]
  },
  "output_schema": {
    "type": "object",
    "properties": {
      "ticket_id": { "type": "string" },
      "category": { "type": "string" },
      "priority": { "type": "string" },
      "assigned_team": { "type": "string" },
      "suggested_response": { "type": "string" },
      "sentiment": { "type": "string" }
    }
  },
  "stages": [
    {
      "id": "log-intake",
      "name": "Log Ticket Intake",
      "component_type": "logger",
      "config": {
        "message": "Processing support ticket",
        "level": "info",
        "data": {
          "ticket_id": "{{input.ticket_id}}",
          "subject": "{{input.subject}}"
        },
        "tags": {
          "component": "support",
          "action": "intake"
        }
      },
      "depends_on": [],
      "position": { "x": 100, "y": 200 }
    },
    {
      "id": "classify-ticket",
      "name": "AI Classification",
      "component_type": "generator",
      "config": {
        "system_prompt": "You are a customer support classification AI. Analyze support tickets and output ONLY valid JSON.\n\nCategories: billing, technical, account, feature_request, bug_report, general\nPriority: critical, high, medium, low\nSentiment: positive, neutral, frustrated, angry\n\nRespond with ONLY this JSON format, no other text:\n{\"category\": \"...\", \"priority\": \"...\", \"sentiment\": \"...\", \"key_issues\": [\"...\"], \"requires_escalation\": true/false}",
        "prompt": "Classify this support ticket:\n\nSubject: {{input.subject}}\n\nMessage: {{input.message}}\n\nCustomer Tier: {{input.customer_tier}}",
        "max_tokens": 200,
        "temperature": 0.1
      },
      "depends_on": ["log-intake"],
      "position": { "x": 300, "y": 200 }
    },
    {
      "id": "parse-classification",
      "name": "Parse Classification",
      "component_type": "json_transform",
      "config": {
        "data": "{{upstream.classify-ticket.content}}",
        "jmespath_expression": "@"
      },
      "depends_on": ["classify-ticket"],
      "position": { "x": 500, "y": 200 }
    },
    {
      "id": "determine-team",
      "name": "Determine Team",
      "component_type": "json_transform",
      "config": {
        "data": {
          "category": "{{upstream.parse-classification.result.category}}",
          "priority": "{{upstream.parse-classification.result.priority}}",
          "customer_tier": "{{input.customer_tier}}"
        },
        "jmespath_expression": "{ team: (category == 'billing' && 'finance_team') || (category == 'technical' && 'engineering_team') || (category == 'bug_report' && 'engineering_team') || (category == 'feature_request' && 'product_team') || (category == 'account' && 'account_team') || 'general_support', escalate: (priority == 'critical') || (customer_tier == 'enterprise') }"
      },
      "depends_on": ["parse-classification"],
      "position": { "x": 700, "y": 200 }
    },
    {
      "id": "generate-response",
      "name": "Generate Suggested Response",
      "component_type": "generator",
      "config": {
        "system_prompt": "You are a helpful customer support agent. Generate a professional, empathetic response to the customer's issue. Be concise but thorough. Address their specific concerns.",
        "prompt": "Generate a response for this ticket:\n\nSubject: {{input.subject}}\nMessage: {{input.message}}\nCategory: {{upstream.parse-classification.result.category}}\nSentiment: {{upstream.parse-classification.result.sentiment}}\n\nProvide a helpful, empathetic response.",
        "max_tokens": 500,
        "temperature": 0.7
      },
      "depends_on": ["parse-classification"],
      "position": { "x": 700, "y": 350 }
    },
    {
      "id": "format-output",
      "name": "Format Final Output",
      "component_type": "json_transform",
      "config": {
        "data": {
          "ticket_id": "{{input.ticket_id}}",
          "customer_email": "{{input.customer_email}}",
          "classification": "{{upstream.parse-classification.result}}",
          "routing": "{{upstream.determine-team.result}}",
          "suggested_response": "{{upstream.generate-response.content}}"
        },
        "jmespath_expression": "{ ticket_id: ticket_id, customer_email: customer_email, category: classification.category, priority: classification.priority, sentiment: classification.sentiment, key_issues: classification.key_issues, assigned_team: routing.team, requires_escalation: routing.escalate, suggested_response: suggested_response }"
      },
      "depends_on": ["determine-team", "generate-response"],
      "position": { "x": 900, "y": 275 }
    },
    {
      "id": "log-complete",
      "name": "Log Completion",
      "component_type": "logger",
      "config": {
        "message": "Ticket triage complete",
        "level": "info",
        "data": "{{upstream.format-output.result}}",
        "tags": {
          "component": "support",
          "action": "triage_complete"
        }
      },
      "depends_on": ["format-output"],
      "position": { "x": 1100, "y": 275 }
    }
  ],
  "output_stage_id": "format-output"
}
