{
  "name": "Auto-categorize blog posts with OpenAI GPT-4, GitHub, and Google Sheets for Astro/Next.js",
  "nodes": [
    {
      "id": "48cac2b7-14b3-4d02-8db7-082c9a8a5cec",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        2192,
        96
      ]
    },
    {
      "id": "1844db4c-6da3-47cb-be7a-2aad32126178",
      "name": "Simple Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        2272,
        288
      ]
    },
    {
      "id": "5467bd31-25c6-4133-ba33-a6c66c332881",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        2128,
        288
      ]
    },
    {
      "id": "d462260a-ba85-4e3b-9ddf-f3e0d37ea249",
      "name": "List posts/articles/pages",
      "type": "n8n-nodes-base.github",
      "position": [
        -240,
        512
      ]
    },
    {
      "id": "3fb2d73a-f707-46dc-8357-67772d6a9b67",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -320,
        208
      ],
      "parameters": {
        "width": 256,
        "height": 480,
        "content": "## Define repository\nDefine repository and directory in which workflow can find articles / post "
      }
    },
    {
      "id": "41217dfe-2aa3-43bc-a415-88d22bb7e042",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1424,
        -576
      ],
      "parameters": {
        "width": null,
        "height": 416,
        "content": "## Get file content\nGet file content and pass it to AI Agent"
      }
    },
    {
      "id": "9985d456-e5ec-4546-9020-ce0a0f9eb57c",
      "name": "Append rows with posts / article analysis",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2768,
        400
      ]
    },
    {
      "id": "2476998a-9a1b-4d40-b9d1-32f6f68d5d02",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2624,
        112
      ],
      "parameters": {
        "width": 368,
        "height": 464,
        "content": "## Save propositions to Google SHeet file\n\nPrepare Google Sheet to contain following columns:\n- FileName\n- Categories\n- Proposed Categories\n- Tags\n- Proposed Tags"
      }
    },
    {
      "id": "b8e31673-da84-4368-9f88-7a9cc2980e43",
      "name": "Get post/article file",
      "type": "n8n-nodes-base.github",
      "position": [
        1504,
        -352
      ]
    },
    {
      "id": "980668bc-d2d2-4452-8f89-b16bec365c91",
      "name": "Get row(s) in sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -512,
        -512
      ]
    },
    {
      "id": "00c43343-2e97-43fb-96d7-a1df7492516e",
      "name": "List FileName only / Remove duplicates",
      "type": "n8n-nodes-base.code",
      "position": [
        -240,
        -512
      ]
    },
    {
      "id": "2f1096f5-0280-4a3b-9a6f-3247bdd1ea44",
      "name": "Get paths to files only from GitHub repository",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        48,
        512
      ]
    },
    {
      "id": "31799c27-6a3b-4220-bceb-e7dcf6277f5f",
      "name": "Get file paths only  from GoogleSheets",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        32,
        -512
      ]
    },
    {
      "id": "3aba4eab-3305-4f86-9976-ef33d5a7c96e",
      "name": "Check new repo files for AI processing",
      "type": "n8n-nodes-base.code",
      "position": [
        800,
        -448
      ]
    },
    {
      "id": "1b542ec1-b963-4064-89fb-40a2a846c5f6",
      "name": "Switch",
      "type": "n8n-nodes-base.switch",
      "position": [
        1008,
        -448
      ]
    },
    {
      "id": "8e129b23-d5a7-4630-ab8a-e780373657db",
      "name": "On form submission",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -832,
        -512
      ]
    },
    {
      "id": "47908ded-1702-483c-9ab9-f60a1ba3c82f",
      "name": "No new posts/articles in GitHub",
      "type": "n8n-nodes-base.form",
      "position": [
        1488,
        -848
      ]
    },
    {
      "id": "a1410a1b-0ce6-490e-912b-3c14107b13bb",
      "name": "Proces finished - Categories and tags added",
      "type": "n8n-nodes-base.form",
      "position": [
        2176,
        -560
      ]
    },
    {
      "id": "ec135e1d-ba4d-4069-8da0-a1d663ad839c",
      "name": "Merge GitHub and Google Sheets read",
      "type": "n8n-nodes-base.merge",
      "position": [
        560,
        -448
      ]
    },
    {
      "id": "ba6b4acc-e548-4df7-9559-bf3ba9b087b6",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        2416,
        288
      ]
    },
    {
      "id": "a637ee7d-af38-420d-8717-e82dbafb3edb",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -592,
        -960
      ],
      "parameters": {
        "width": 256,
        "height": 608,
        "content": "## Get list of posts from Google Sheets\n\nThis step prevents repeating usage of AI Agent for previously analysed posts/pages.\n\nPrepare Google Sheet to contain following columns:\n- FileName\n- Categories"
      }
    },
    {
      "id": "3fa92146-9b0d-45a9-be49-9cf6be9d66ec",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -320,
        -960
      ],
      "parameters": {
        "width": 256,
        "height": 608,
        "content": "## List FileNames only and Remove duplicates\n\nThis function filters out duplicate items from a list of Google Sheet objects based on the value of each item’s `FileName` property"
      }
    },
    {
      "id": "1653cada-fdf6-418e-aab6-bb715d25ebf1",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -48,
        -960
      ],
      "parameters": {
        "width": 320,
        "height": 608,
        "content": "## Conver JSON to Array\n\nConvert from:\n```\n{\n\"path\": \"src1\"\n},\n{\n\"path\": \"src2\"\n},\n```\nTo\n```\n{\n\"googlesheetsPaths\": \n[\n\"src1\", \n\"src2\"\n]\n}\n```"
      }
    },
    {
      "id": "45a2544a-424d-466c-9fa4-afa25ea1f08c",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1424,
        -1008
      ],
      "parameters": {
        "width": null,
        "height": 352,
        "content": "## No new files in GitHub repository\n"
      }
    },
    {
      "id": "8b7ed568-b0fb-4589-9d5d-cf10699794d1",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -48,
        208
      ],
      "parameters": {
        "width": 320,
        "height": 480,
        "content": "## Conver JSON to Array\n\nConvert complex JSON to Array\n```\n{\n\"githubPaths\": \n[\n\"src1\", \n\"src2\"\n]\n}\n```"
      }
    },
    {
      "id": "c39a9ece-2d68-47c0-b4e5-82e6acb0eb1e",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        720,
        -608
      ],
      "parameters": {
        "width": 256,
        "height": 320,
        "content": "## Compare list from Google Sheets with list from Github\n"
      }
    },
    {
      "id": "97c232f0-6358-442d-a8c1-8234e7afff4d",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2080,
        -288
      ],
      "parameters": {
        "width": 480,
        "height": 736,
        "content": "## AI Agent\n\nRole of **AI Agent** is to:\n- Analyse content of the file (post/page)\n- Assign categories and tags per analysed file\n- Return JSON in format by `Structured output` like below:\n\n```\n{\n  \"o"
      }
    },
    {
      "id": "935037f1-860d-42a3-b898-fccbd545c145",
      "name": "Loop Over Posts/Pages",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        1776,
        -352
      ]
    },
    {
      "id": "779d1b8f-1523-4c49-bdcc-6f4ed34ca301",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2096,
        -736
      ],
      "parameters": {
        "width": null,
        "height": 352,
        "content": "## No new files in GitHub repository\n"
      }
    }
  ],
  "connections": {
    "Switch": {
      "main": [
        [
          {
            "node": "No new posts/articles in GitHub",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get post/article file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Append rows with posts / article analysis",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "On form submission": {
      "main": [
        [
          {
            "node": "Get row(s) in sheet",
            "type": "main",
            "index": 0
          },
          {
            "node": "List posts/articles/pages",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get row(s) in sheet": {
      "main": [
        [
          {
            "node": "List FileName only / Remove duplicates",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get post/article file": {
      "main": [
        [
          {
            "node": "Loop Over Posts/Pages",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Posts/Pages": {
      "main": [
        [
          {
            "node": "Proces finished - Categories and tags added",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "AI Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "List posts/articles/pages": {
      "main": [
        [
          {
            "node": "Get paths to files only from GitHub repository",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge GitHub and Google Sheets read": {
      "main": [
        [
          {
            "node": "Check new repo files for AI processing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check new repo files for AI processing": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get file paths only  from GoogleSheets": {
      "main": [
        [
          {
            "node": "Merge GitHub and Google Sheets read",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "List FileName only / Remove duplicates": {
      "main": [
        [
          {
            "node": "Get file paths only  from GoogleSheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append rows with posts / article analysis": {
      "main": [
        [
          {
            "node": "Loop Over Posts/Pages",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get paths to files only from GitHub repository": {
      "main": [
        [
          {
            "node": "Merge GitHub and Google Sheets read",
            "type": "main",
            "index": 1
          }
        ]
      ]
    }
  }
}