{
  "id": "G2rpmq6qJiMyA708",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "jekyll-autopost",
  "tags": [],
  "nodes": [
    {
      "id": "5efad78c-f4ea-490e-83c9-9c8c34eaeb21",
      "name": "Start",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -1740,
        420
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "884e4291-6483-4865-a1c4-35e0d466cfab",
      "name": "Read CSV",
      "type": "n8n-nodes-base.readBinaryFile",
      "position": [
        -1480,
        460
      ],
      "parameters": {
        "filePath": "/data/recipes.csv",
        "dataPropertyName": "=data"
      },
      "typeVersion": 1
    },
    {
      "id": "bfddf1ce-7d31-4cca-b249-be0ffbc2978c",
      "name": "Split In Batches",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -1080,
        440
      ],
      "parameters": {
        "options": {},
        "batchSize": 1
      },
      "typeVersion": 1
    },
    {
      "id": "53a35d7c-b210-4b27-82e4-61fe7eba9bf4",
      "name": "Wait Until Publish",
      "type": "n8n-nodes-base.wait",
      "disabled": true,
      "position": [
        -220,
        -180
      ],
      "parameters": {
        "unit": "=",
        "amount": "={{ $json.data_pubblicazione }}"
      },
      "typeVersion": 1
    },
    {
      "id": "d885e9ab-0f9c-46c2-af27-914628718365",
      "name": "Commit Markdown",
      "type": "n8n-nodes-base.github",
      "position": [
        -100,
        360
      ],
      "parameters": {
        "owner": {
          "__rl": true,
          "mode": "",
          "value": "antonio-backend-projects"
        },
        "filePath": "={{ $json[\"markdownPath\"] }}",
        "resource": "file",
        "repository": {
          "__rl": true,
          "mode": "list",
          "value": "jekyll-recipe-ai",
          "cachedResultUrl": "https://github.com/antonio-backend-projects/jekyll-recipe-ai",
          "cachedResultName": "jekyll-recipe-ai"
        },
        "fileContent": "={{ $('Code').item.json.markdownContent }}",
        "commitMessage": "=={{ 'Add recipe: ' + $json.titolo }}"
      },
      "credentials": {
        "githubApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "78d9ca4f-392d-47f6-98c1-b5b2a671c736",
      "name": "Post on X",
      "type": "n8n-nodes-base.twitter",
      "disabled": true,
      "position": [
        160,
        -220
      ],
      "parameters": {
        "operation": "createTweet"
      },
      "typeVersion": 1
    },
    {
      "id": "319bd723-ff2c-40ca-9519-b38107323b49",
      "name": "Post on LinkedIn",
      "type": "n8n-nodes-base.linkedIn",
      "disabled": true,
      "position": [
        340,
        200
      ],
      "parameters": {
        "text": "={{$json.titolo}}",
        "additionalFields": {}
      },
      "typeVersion": 1
    },
    {
      "id": "7e6d5cac-befd-4cb6-8564-b4268e9dd04e",
      "name": "Extract from File",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        -1260,
        -40
      ],
      "parameters": {
        "options": {
          "delimiter": ";"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "f72b0e71-92bb-4eb5-ad18-5c5abecd3699",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -980,
        -100
      ],
      "parameters": {
        "color": 3,
        "width": 420,
        "height": 440,
        "content": "## Write SEO Optimized Blog Post\n\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "49cfd514-17d0-467b-b658-7a1cc64fffc2",
      "name": "Copywriter AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -900,
        0
      ],
      "parameters": {
        "text": "=You are a SEO-first food writer for an Italian recipe blog built with Jekyll.\nWrite an article of 800\u20131000 words, with a professional yet warm and accessible tone.\nDO NOT include any front matter.\n\n### POST INPUT\n- Recipe title: {{ $json.titolo }}\n- Description / brief: {{ $json.prompt_descrizione }}\n- Main keyword: {{ $json.keyword_principale }}\n- Secondary keywords (to integrate naturally): {{ $json.keyword_secondarie }}\n\n### GUIDELINES\n1. Start the article with an H2 using the exact title.  \n2. Include the **main keyword** in the title, in the first paragraph, and in at least one H3.  \n3. Structure the article in Markdown with the following blocks **in order**:\n   - Introduction (brief history or fun fact about the recipe)\n   - *Ingredients* section (bullet list)\n   - *Instructions* section (numbered steps)\n   - Chef\u2019s tips / tricks for a perfect result\n   - Wine or beverage pairing\n   - Possible variations or substitutions\n   - FAQ (at least 3 short Q&A entries)\n   - Conclusion with **CTA**: invite the reader to try the recipe and explore other recipes on the blog\n4. Highlight keywords using **bold** or *italic* where appropriate (but don\u2019t overdo it).  \n5. Keep sentences and paragraphs short, use bullet points and H3s for readability.  \n6. Avoid emojis and overly promotional language; tone should be friendly yet authoritative.  \n7. The output must be **only the Markdown content** of the article, with no extra explanations.\n\n### SEO GOAL\n- Optimize for the main keyword without keyword stuffing; distribute secondary keywords naturally.\n- Use Italian synonyms where relevant (e.g., \u201cfunghi porcini freschi\u201d, \u201criso Carnaroli\u201d, etc.).",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 1.8
    },
    {
      "id": "16b047d2-0d4d-4fa7-a4f9-9b65025d51f0",
      "name": "gpt-4o-mini",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -900,
        200
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "27288133-400d-4957-b7d2-b1ee2260c12a",
      "name": "Code",
      "type": "n8n-nodes-base.code",
      "position": [
        -400,
        20
      ],
      "parameters": {
        "jsCode": "// Item proveniente da \"Split In Batches\" (indice 0)\nconst base = $items(\"Split In Batches\")[0].json;\n\n// 1. Slug SEO-friendly\nconst slug = base.titolo\n  .toLowerCase()\n  .replace(/[^a-z0-9]+/g, '-')\n  .replace(/(^-|-$)/g, '');\n\n// 2. Front-matter Jekyll\nconst frontMatter = `---\\ntitle: \"${base.titolo}\"\\ndate: ${base.data_pubblicazione} +0200\\nlayout: post\\n---`;\n\n// 3. Contenuto AI\nconst aiContent = $json.output.trim();\n\n// 4. Markdown completo\nconst markdown = `${frontMatter}\\n\\n${aiContent}`;\n\nreturn [\n  {\n    json: {\n      ...base,                // mantiene titolo, keyword\u2026\n      slug,\n      markdownPath: `_posts/${base.data_pubblicazione.slice(0,10)}-${slug}.md`,\n      markdownContent: markdown\n    }\n  }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "a7816b95-b5a0-44b6-af54-a90177524f7e",
      "name": "Remove the processed csv line",
      "type": "n8n-nodes-base.code",
      "position": [
        -840,
        500
      ],
      "parameters": {
        "jsCode": "const fs = require('fs');\nconst CSV_PATH = '/data/recipes.csv';\n\n// 1. Leggi il CSV attuale\nconst rawCsv = fs.readFileSync(CSV_PATH, 'utf8').trim();\nconst rows   = rawCsv.split('\\n');\n\n// 2. Filtra via la riga pubblicata\nconst filtered = rows.filter((row, idx) => {\n\tif (idx === 0) return true;            // header\n\treturn row.split(';')[0] !== $json.titolo;\n});\n\n// 3. Se \u00e8 cambiato, riscrivi il file\nif (filtered.length !== rows.length) {\n\tconst newCsv = filtered.join('\\n') + '\\n';\n\tfs.writeFileSync(CSV_PATH, newCsv, 'utf8');\n}\n\n// 4. Restituisci l\u2019item JSON senza binari inutili\n// 4. Restituisci l\u2019item originale (senza binari aggiuntivi)\nreturn [\n\t{\n\t\tjson: $json\n\t}\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "39814681-6340-4b30-a4b9-14bc8298243f",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -1660,
        -180
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 8
            }
          ]
        }
      },
      "typeVersion": 1.2
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "9ce77bdb-3568-43ea-8e92-c5a282b870e4",
  "connections": {
    "Code": {
      "main": [
        [
          {
            "node": "Wait Until Publish",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Start": {
      "main": [
        [
          {
            "node": "Read CSV",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read CSV": {
      "main": [
        [
          {
            "node": "Extract from File",
            "type": "main",
            "index": 0
          },
          {
            "node": "Remove the processed csv line",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Post on X": {
      "main": [
        [
          {
            "node": "Post on LinkedIn",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "gpt-4o-mini": {
      "ai_languageModel": [
        [
          {
            "node": "Copywriter AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Commit Markdown": {
      "main": [
        [
          {
            "node": "Post on X",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Read CSV",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split In Batches": {
      "main": [
        [
          {
            "node": "Copywriter AI Agent",
            "type": "main",
            "index": 0
          },
          {
            "node": "Remove the processed csv line",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from File": {
      "main": [
        [
          {
            "node": "Split In Batches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait Until Publish": {
      "main": [
        [
          {
            "node": "Commit Markdown",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Copywriter AI Agent": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Remove the processed csv line": {
      "main": [
        []
      ]
    }
  }
}