{
  "name": "lead-triage-v1",
  "type": "sample_workflow_spec",
  "purpose": "Classify inbound leads, prepare a human-reviewed reply, and log the next action without sending anything automatically.",
  "trigger": {
    "source": "form_submission_or_email_parser",
    "required_fields": [
      "name",
      "email",
      "company_or_project",
      "message",
      "received_at"
    ],
    "optional_fields": [
      "budget",
      "deadline",
      "current_tools",
      "sample_input_url"
    ]
  },
  "steps": [
    {
      "id": "validate_input",
      "kind": "deterministic",
      "description": "Check required fields and route incomplete records to manual review."
    },
    {
      "id": "normalize_record",
      "kind": "deterministic",
      "description": "Normalize company, email, deadline, budget, and tool names for downstream routing."
    },
    {
      "id": "classify_intent",
      "kind": "llm",
      "model_policy": "Use a small/fast model for classification unless the message is long or ambiguous.",
      "outputs": [
        "intent",
        "urgency",
        "fit_score",
        "missing_fields",
        "recommended_next_step",
        "confidence"
      ]
    },
    {
      "id": "route_record",
      "kind": "deterministic",
      "description": "Route high-fit urgent leads to owner review, low-confidence leads to manual queue, and poor-fit leads to polite decline."
    },
    {
      "id": "draft_reply",
      "kind": "llm",
      "description": "Draft a concise reply asking for trigger, tools, sample input, expected output, blocker, and deadline."
    },
    {
      "id": "write_log",
      "kind": "deterministic",
      "description": "Append the decision, model output, confidence, and next action to the log."
    },
    {
      "id": "notify_owner",
      "kind": "integration",
      "description": "Notify the owner by email, Slack, or task system with the draft reply and recommended action."
    }
  ],
  "approval_gates": [
    {
      "action": "send_external_email",
      "required": true,
      "reason": "External communication should be approved by a human before sending."
    },
    {
      "action": "quote_price",
      "required": true,
      "reason": "Pricing should be reviewed against scope, access, and risk."
    },
    {
      "action": "mutate_production_data",
      "required": true,
      "reason": "Production data changes need explicit approval and rollback notes."
    }
  ],
  "fallbacks": [
    {
      "condition": "confidence_below_0_72",
      "action": "queue_for_manual_review"
    },
    {
      "condition": "missing_required_fields",
      "action": "request_missing_fields"
    },
    {
      "condition": "integration_failure",
      "action": "write_failure_log_and_notify_owner"
    }
  ],
  "test_cases": [
    {
      "name": "high_fit_urgent_workflow_request",
      "expected": "route_to_owner_review"
    },
    {
      "name": "unclear_message_missing_tools",
      "expected": "draft_clarifying_questions"
    },
    {
      "name": "low_fit_sales_spam",
      "expected": "archive_or_decline"
    },
    {
      "name": "integration_failure",
      "expected": "failure_log_and_owner_notification"
    }
  ],
  "handoff_files": [
    "lead-triage-v1.workflow.json",
    "lead-triage-v1-runbook.md"
  ],
  "notes": [
    "This is a sample portable workflow spec, not a claim that every client stack should use this exact structure.",
    "A real delivery would be adapted to the client's n8n, Make, Zapier, codebase, CRM, email, or internal tool stack.",
    "The first slice should prove one complete path before expanding into a broader automation system."
  ]
}
