{
  "name": "ADIK-01 Content Automation (HF Inference)",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours",
              "hoursInterval": 6
            }
          ]
        }
      },
      "id": "trigger-01",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.1,
      "position": [240, 300]
    },
    {
      "parameters": {
        "jsCode": "// Topik harian — bisa diganti dengan baca dari Google Sheets / Airtable\nconst topics = [\n  'productivity tips untuk founder Indonesia',\n  'review barbershop premium Jakarta',\n  'AI tools untuk content creator',\n  'self-hosted automation gratis 2026'\n];\nconst topic = topics[Math.floor(Math.random() * topics.length)];\nreturn [{ json: { topic, requested_at: new Date().toISOString() } }];"
      },
      "id": "topic-picker",
      "name": "Pick Topic",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [460, 300]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://127.0.0.1:7860/api/hf/inference",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"model\": \"mistralai/Mistral-7B-Instruct-v0.3\",\n  \"inputs\": \"Tulis artikel blog 400 kata dalam Bahasa Indonesia tentang: {{ $json.topic }}. Format markdown, ada heading H2 dan H3, tone profesional tapi friendly.\",\n  \"parameters\": { \"max_new_tokens\": 800, \"temperature\": 0.7, \"return_full_text\": false }\n}",
        "options": {}
      },
      "id": "hf-call",
      "name": "HF Inference (Mistral)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [680, 300]
    },
    {
      "parameters": {
        "jsCode": "const out = $input.first().json;\nlet article = '';\nif (Array.isArray(out) && out[0]?.generated_text) {\n  article = out[0].generated_text;\n} else if (out.generated_text) {\n  article = out.generated_text;\n} else {\n  article = JSON.stringify(out);\n}\n\n// Generate variant social media\nconst socialPost = article.split('\\n').filter(Boolean)[0].slice(0, 240);\n\nreturn [{ json: {\n  topic: $('Pick Topic').first().json.topic,\n  article_markdown: article,\n  social_post: socialPost,\n  generated_at: new Date().toISOString(),\n  channel: 'sparkmind-adik'\n}}];"
      },
      "id": "parse-output",
      "name": "Parse & Variant",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [900, 300]
    },
    {
      "parameters": {
        "operation": "write",
        "fileName": "=/home/user/data/n8n/output/article-{{ $now.toFormat('yyyyMMdd-HHmmss') }}.md",
        "dataPropertyName": "article_markdown",
        "options": {}
      },
      "id": "save-file",
      "name": "Save Markdown",
      "type": "n8n-nodes-base.readWriteFile",
      "typeVersion": 1,
      "position": [1120, 300]
    }
  ],
  "connections": {
    "Schedule Trigger": { "main": [[{ "node": "Pick Topic", "type": "main", "index": 0 }]] },
    "Pick Topic":       { "main": [[{ "node": "HF Inference (Mistral)", "type": "main", "index": 0 }]] },
    "HF Inference (Mistral)": { "main": [[{ "node": "Parse & Variant", "type": "main", "index": 0 }]] },
    "Parse & Variant":  { "main": [[{ "node": "Save Markdown", "type": "main", "index": 0 }]] }
  },
  "active": false,
  "settings": { "executionOrder": "v1" },
  "tags": [{ "name": "adik-os" }, { "name": "content" }]
}
