{
  "name": "Case Study Auto-Publish (Mon+Thu 9AM CET)",
  "active": false,
  "nodes": [
    {
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.1,
      "parameters": {
        "rule": {
          "interval": [{ "field": "cronExpression", "expression": "0 8 * * 1,4" }]
        }
      },
      "position": [0, 0]
    },
    {
      "name": "Get Rotation State",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "parameters": {
        "method": "GET",
        "url": "http://host.docker.internal:3000/api/internal/publish-case-study",
        "options": {}
      },
      "position": [220, 0]
    },
    {
      "name": "Generate Case Study (Mistral Large)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "parameters": {
        "method": "POST",
        "url": "https://api.mistral.ai/v1/chat/completions",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            { "name": "Authorization", "value": "=Bearer {{ $env.MISTRAL_API_KEY }}" },
            { "name": "Content-Type", "value": "application/json" }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            { "name": "model", "value": "mistral-large-latest" },
            { "name": "response_format", "value": "={ \"type\": \"json_object\" }" },
            { "name": "messages", "value": "=[{\"role\":\"system\",\"content\":\"You are a senior business case study writer for Hyperion Consulting, an AI strategy consultancy based in Europe. You have deep knowledge of AI adoption patterns, challenges, ROI benchmarks, and transformation journeys across all industries as of 2025-2026.\\n\\nYou write METHODOLOGY DEMONSTRATIONS — illustrative examples of how Hyperion's frameworks work in practice. These are NOT real client stories. You MUST NOT invent, fabricate, or use any real company names, real people names, or real client testimonials. Every scenario uses generic role descriptors only.\\n\\nOutput strict JSON only — no prose, no markdown, no text outside the JSON object.\"},{\"role\":\"user\",\"content\":\"Generate a methodology demonstration case study for:\\n- Industry: {{ $('Get Rotation State').item.json.industry }}\\n- Company size: {{ $('Get Rotation State').item.json.companySizeLabel }}\\n- Context: European market, 2025-2026 AI adoption wave\\n\\nDraw on your knowledge of real industry AI challenges and benchmarks for this sector and company size. Be specific and credible — cite realistic pain points, technology choices, and outcome ranges typical for this industry.\\n\\nOutput this exact JSON schema (no other keys, no additional fields):\\n{\\n  \\\"slug\\\": \\\"[industry-hint]-[size-hint]-ai-2026-[3-word-outcome]\\\",\\n  \\\"title\\\": \\\"How a [European adjective] [industry] [company type] [achieved specific outcome]\\\",\\n  \\\"summary\\\": \\\"3-sentence executive summary: context, approach, key outcome. Must state this is an illustrative methodology demonstration.\\\",\\n  \\\"industry\\\": \\\"{{ $('Get Rotation State').item.json.industry }}\\\",\\n  \\\"companySize\\\": \\\"{{ $('Get Rotation State').item.json.companySize }}\\\",\\n  \\\"companySizeLabel\\\": \\\"{{ $('Get Rotation State').item.json.companySizeLabel }}\\\",\\n  \\\"challenge\\\": \\\"2-paragraph description of the specific operational or strategic challenge this company type commonly faces.\\\",\\n  \\\"solution\\\": \\\"2-paragraph description of the AI solution approach Hyperion Consulting typically designs and implements for this challenge.\\\",\\n  \\\"results\\\": [{\\\"metric\\\": \\\"[Specific KPI]\\\",\\\"value\\\": \\\"[15-40%]\\\",\\\"improvement\\\": \\\"typical reduction/increase/faster/saved\\\"},{\\\"metric\\\": \\\"[Operational metric]\\\",\\\"value\\\": \\\"[realistic number]\\\",\\\"improvement\\\": \\\"typical direction\\\"},{\\\"metric\\\": \\\"[Business outcome]\\\",\\\"value\\\": \\\"[realistic number]\\\",\\\"improvement\\\": \\\"typical direction\\\"},{\\\"metric\\\": \\\"[Time or cost metric]\\\",\\\"value\\\": \\\"[realistic number]\\\",\\\"improvement\\\": \\\"typical direction\\\"}],\\n  \\\"technologies\\\": [\\\"Mistral AI\\\", \\\"[2-3 relevant real tools for this industry]\\\"],\\n  \\\"timeline\\\": \\\"[8-20] weeks\\\",\\n  \\\"isMethodologyDemo\\\": true,\\n  \\\"publishedAt\\\": \\\"{{ new Date().toISOString() }}\\\",\\n  \\\"generatedAt\\\": \\\"{{ new Date().toISOString() }}\\\"\\n}\\n\\nHard rules:\\n- NEVER use a real company name, real brand name, or real person name anywhere in any field\\n- Title MUST use the pattern 'How a [European adjective] [industry] [company type] [achieved X]' — no named companies\\n- NEVER include testimonials, quotes, or references to specific named individuals\\n- Metrics: 15-40% improvements — never 10x, never >50% unless a very specific narrow KPI\\n- Improvement language must include 'typical' to signal illustrative nature (e.g. 'typical reduction')\\n- Technologies must include Mistral AI as the AI backbone\\n- Slug: kebab-case, max 60 chars, must include year (2026)\\n- Results: exactly 4 items\\n- No markdown in JSON string values — plain text only\"}]" }
          ]
        },
        "options": {}
      },
      "position": [440, 0]
    },
    {
      "name": "Sign and Publish",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "parameters": {
        "jsCode": "const crypto = require('crypto');\nconst body = $('Generate Case Study (Mistral Large)').item.json.choices[0].message.content;\nconst secret = $env.N8N_WEBHOOK_SECRET;\nconst sig = 'hmac-sha256=' + crypto.createHmac('sha256', secret).update(body).digest('hex');\nreturn [{ json: { body, sig } }];"
      },
      "position": [660, 0]
    },
    {
      "name": "POST to Publish Endpoint",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "parameters": {
        "method": "POST",
        "url": "http://host.docker.internal:3000/api/internal/publish-case-study",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            { "name": "x-webhook-signature", "value": "={{ $json.sig }}" },
            { "name": "Content-Type", "value": "application/json" }
          ]
        },
        "sendBody": true,
        "specifyBody": "string",
        "body": "={{ $json.body }}",
        "options": {}
      },
      "position": [880, 0]
    },
    {
      "name": "Notify Telegram",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "parameters": {
        "method": "POST",
        "url": "=https://api.telegram.org/bot{{ $env.TELEGRAM_BOT_TOKEN }}/sendMessage",
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            { "name": "chat_id", "value": "={{ $env.TELEGRAM_CHAT_ID }}" },
            { "name": "text", "value": "=📚 New case study published!\\n\\nIndustry: {{ $('Get Rotation State').item.json.industry }}\\nSize: {{ $('Get Rotation State').item.json.companySizeLabel }}\\n\\nhttps://hyperion-consulting.io/case-studies/{{ $('POST to Publish Endpoint').item.json.slug }}" },
            { "name": "parse_mode", "value": "Markdown" }
          ]
        },
        "options": {}
      },
      "position": [1100, -80]
    },
    {
      "name": "Notify Slack",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "parameters": {
        "method": "POST",
        "url": "={{ $env.SLACK_WEBHOOK_URL }}",
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            { "name": "text", "value": "=📚 New case study published!\\n\\nIndustry: {{ $('Get Rotation State').item.json.industry }} | Size: {{ $('Get Rotation State').item.json.companySizeLabel }}\\nhttps://hyperion-consulting.io/case-studies/{{ $('POST to Publish Endpoint').item.json.slug }}" }
          ]
        },
        "options": {}
      },
      "position": [1100, 80]
    }
  ],
  "connections": {
    "Schedule Trigger": {
      "main": [[{ "node": "Get Rotation State", "type": "main", "index": 0 }]]
    },
    "Get Rotation State": {
      "main": [[{ "node": "Generate Case Study (Mistral Large)", "type": "main", "index": 0 }]]
    },
    "Generate Case Study (Mistral Large)": {
      "main": [[{ "node": "Sign and Publish", "type": "main", "index": 0 }]]
    },
    "Sign and Publish": {
      "main": [[{ "node": "POST to Publish Endpoint", "type": "main", "index": 0 }]]
    },
    "POST to Publish Endpoint": {
      "main": [[
        { "node": "Notify Telegram", "type": "main", "index": 0 },
        { "node": "Notify Slack", "type": "main", "index": 0 }
      ]]
    }
  },
  "settings": {
    "executionOrder": "v1"
  }
}
