{
  "schema": "mindstudio.app/v1",
  "name": "Helpdesk Hero",
  "description": "Tier-1 ticket triage and FAQ deflection.",
  "blocks": [
    {
      "id": "intake",
      "type": "trigger.webhook",
      "label": "Inbound ticket",
      "fields": ["from_email", "subject", "body"]
    },
    {
      "id": "classify",
      "type": "ai.classifier",
      "label": "Classify intent",
      "model": "gpt-4.1-mini",
      "labels": ["billing", "bug", "how-to", "sales", "other"],
      "input": "{{intake.subject}}\n\n{{intake.body}}"
    },
    {
      "id": "answer-faq",
      "type": "ai.completion",
      "label": "Answer how-to from FAQ",
      "model": "gpt-4.1-mini",
      "system": "You are a friendly, concise tier-1 support agent. Answer ONLY using the supplied FAQ. If the answer isn't in the FAQ, reply 'NO_MATCH'. Never invent product behavior.",
      "knowledge": ["faq.md"],
      "when": "{{classify.label}} == 'how-to'"
    },
    {
      "id": "route-human",
      "type": "action.send-email",
      "label": "Hand off to human queue",
      "to": "support@example.com",
      "subject": "[{{classify.label}}] {{intake.subject}}",
      "body": "From: {{intake.from_email}}\n\n{{intake.body}}\n\n— Auto-routed by Helpdesk Hero",
      "when": "{{answer-faq.text}} == 'NO_MATCH' || {{classify.label}} != 'how-to'"
    },
    {
      "id": "reply-customer",
      "type": "action.send-email",
      "label": "Reply to customer",
      "to": "{{intake.from_email}}",
      "subject": "Re: {{intake.subject}}",
      "body": "{{answer-faq.text}}\n\n— Helpdesk Hero (auto-reply)",
      "when": "{{answer-faq.text}} != 'NO_MATCH'"
    },
    {
      "id": "daily-report",
      "type": "trigger.schedule",
      "schedule": "0 17 * * 1-5",
      "label": "Daily 5pm ops report"
    },
    {
      "id": "slack-report",
      "type": "action.slack",
      "label": "Post Slack summary",
      "channel": "#support-ops",
      "blocks": [
        {"type": "header", "text": "Helpdesk Hero — Daily Summary"},
        {"type": "section", "text": "Today: {{stats.tickets_total}} tickets · {{stats.deflected}} deflected · {{stats.routed}} routed to human"}
      ],
      "when": "trigger == 'daily-report'"
    }
  ],
  "knowledge": {
    "faq.md": "# Replace with your product FAQ\n\n## How do I reset my password?\nClick 'Forgot password' on the login screen. We email a magic link.\n\n## How do I cancel?\nSettings → Billing → Cancel subscription. No questions asked.\n\n## Where do I find my invoices?\nSettings → Billing → Invoices."
  }
}
