{
  "name": "Automatically save & organize LINE message files in Google Drive with Sheets logging",
  "nodes": [
    {
      "id": "47c9f83b-5590-4ffc-825c-5fee72e8ef87",
      "name": "Get Config",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1220,
        -200
      ]
    },
    {
      "id": "1514cec1-bd12-4ce4-99af-bd2465026822",
      "name": "Create Date Folder",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1700,
        80
      ]
    },
    {
      "id": "a584238e-1d53-46ff-8cfc-437e14ea71d9",
      "name": "Set Date Folder ID",
      "type": "n8n-nodes-base.code",
      "position": [
        1960,
        -20
      ]
    },
    {
      "id": "aa480dc9-935e-4a6e-a6c6-2559255ae1c2",
      "name": "Create File Type Folder",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1700,
        400
      ]
    },
    {
      "id": "d5ed8981-5b65-45a3-8ff4-c00902756bb9",
      "name": "Upload File to Google Drive",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1600,
        640
      ]
    },
    {
      "id": "92787455-6839-455f-a939-6927660bc215",
      "name": "Determine Folder Info",
      "type": "n8n-nodes-base.code",
      "position": [
        1960,
        -280
      ]
    },
    {
      "id": "f4e30758-986e-4dd4-bc85-f2953e883bfe",
      "name": "Search Date Folder",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        980,
        0
      ]
    },
    {
      "id": "e74d65bc-be7f-43d0-8b0a-ee6316b4aff9",
      "name": "Merge Event and Config Data",
      "type": "n8n-nodes-base.merge",
      "position": [
        1480,
        -280
      ]
    },
    {
      "id": "f380d584-32aa-435f-8e8e-6d1d05932bd2",
      "name": "Check Existing Date Folder",
      "type": "n8n-nodes-base.if",
      "position": [
        1220,
        0
      ]
    },
    {
      "id": "96dc0853-67ec-4cfc-b40c-0cce63f51e96",
      "name": "Check Existing File Type Folder",
      "type": "n8n-nodes-base.if",
      "position": [
        1220,
        320
      ]
    },
    {
      "id": "742cb154-3b23-423d-8df6-53a82f0d8aab",
      "name": "Merge Final Parent Folder Data",
      "type": "n8n-nodes-base.merge",
      "position": [
        2280,
        400
      ]
    },
    {
      "id": "1003b29d-9140-4961-90d4-b94e4d33dc69",
      "name": "Search File Type Folder",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        980,
        320
      ]
    },
    {
      "id": "8015eb75-0c38-4c3b-a29f-f04dedf79cee",
      "name": "Set File Type Folder ID",
      "type": "n8n-nodes-base.code",
      "position": [
        1960,
        320
      ]
    },
    {
      "id": "b59d58c7-cb8c-4edc-a7e7-533675c39a96",
      "name": "Configure Final Parent Folder ID",
      "type": "n8n-nodes-base.code",
      "position": [
        960,
        640
      ]
    },
    {
      "id": "683c83fc-e4b7-4a0d-b5f0-8958d0743faf",
      "name": "Process Event and Config Data",
      "type": "n8n-nodes-base.code",
      "position": [
        1680,
        -280
      ]
    },
    {
      "id": "fb5bd15c-bb0a-420b-a14b-ed5df5ecd691",
      "name": "Get File Binary Content",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1180,
        640
      ]
    },
    {
      "id": "f064ba27-a5a8-4cca-afb8-3e099fb5abc8",
      "name": "Log File Details to Google Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1820,
        640
      ]
    },
    {
      "id": "fd936998-6ba0-4dbe-b406-c785f89181dd",
      "name": "Check Reply Enabled Flag",
      "type": "n8n-nodes-base.if",
      "position": [
        2040,
        640
      ]
    },
    {
      "id": "7d1f19e7-cb6c-4f5d-8a10-b84e9e06345a",
      "name": "Check if Store by Date is Enabled",
      "type": "n8n-nodes-base.if",
      "position": [
        1420,
        80
      ]
    },
    {
      "id": "8644134e-673c-4360-8831-71c048c1522d",
      "name": "Check if Store by File Type is Enabled",
      "type": "n8n-nodes-base.if",
      "position": [
        1420,
        400
      ]
    },
    {
      "id": "f6b24396-a854-42c4-ae70-55095d637b9a",
      "name": "LINE Webhook Listener",
      "type": "n8n-nodes-base.webhook",
      "position": [
        980,
        -300
      ]
    },
    {
      "id": "3b1ca174-f5fc-4b01-90f4-be9240f8be77",
      "name": "Send LINE Reply Message",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2280,
        620
      ]
    },
    {
      "id": "87465dac-4557-4ee4-ae21-b36aab37c884",
      "name": "Validate File Type",
      "type": "n8n-nodes-base.code",
      "position": [
        1380,
        640
      ]
    },
    {
      "id": "00ddc2ae-4782-4079-947e-2fda99c0f037",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        220,
        -380
      ],
      "parameters": {
        "width": 2320,
        "height": 320,
        "content": "## Workflow Entry & Configuration\nThis section initializes the workflow by listening to incoming requests from \nthe LINE Messaging API and retrieving configuration details from Google Sheets. \nIt merg"
      }
    },
    {
      "id": "ccae9a3d-0a46-4c06-b94b-c3bd08d10df1",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        220,
        -40
      ],
      "parameters": {
        "width": 2320,
        "height": 340,
        "content": "## Folder Search & Creation\nThis section handles the logic for finding or creating the appropriate Google Drive folders.\nIt checks if a date folder exists (when Store by Date is enabled) and whether a"
      }
    },
    {
      "id": "b9272975-3e0d-436c-b8e3-98fcb8cfc893",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        220,
        600
      ],
      "parameters": {
        "width": 2320,
        "height": 320,
        "content": "## Upload, Log, & Reply\nOnce the file is validated and the correct folder determined, the workflow uploads the file\nto Google Drive and logs the details in a Google Sheet. Finally, it checks whether r"
      }
    },
    {
      "id": "85a84d38-6992-439d-bdaa-de37b0dac554",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        220,
        320
      ],
      "parameters": {
        "width": 2320,
        "height": 260,
        "content": "## File Retrieval & Validation\nIn this group, the workflow fetches the binary content of the file from the LINE API\nand validates whether the file type is allowed (e.g., image, audio, video). If the \n"
      }
    }
  ],
  "connections": {
    "Get Config": {
      "main": [
        [
          {
            "node": "Merge Event and Config Data",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Create Date Folder": {
      "main": [
        [
          {
            "node": "Set Date Folder ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search Date Folder": {
      "main": [
        [
          {
            "node": "Check Existing Date Folder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Date Folder ID": {
      "main": [
        [
          {
            "node": "Search File Type Folder",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge Final Parent Folder Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate File Type": {
      "main": [
        [
          {
            "node": "Upload File to Google Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Determine Folder Info": {
      "main": [
        [
          {
            "node": "Search Date Folder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "LINE Webhook Listener": {
      "main": [
        [
          {
            "node": "Merge Event and Config Data",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get Config",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create File Type Folder": {
      "main": [
        [
          {
            "node": "Set File Type Folder ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get File Binary Content": {
      "main": [
        [
          {
            "node": "Validate File Type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search File Type Folder": {
      "main": [
        [
          {
            "node": "Check Existing File Type Folder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set File Type Folder ID": {
      "main": [
        [
          {
            "node": "Merge Final Parent Folder Data",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Check Reply Enabled Flag": {
      "main": [
        [
          {
            "node": "Send LINE Reply Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Existing Date Folder": {
      "main": [
        [
          {
            "node": "Set Date Folder ID",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Check if Store by Date is Enabled",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge Event and Config Data": {
      "main": [
        [
          {
            "node": "Process Event and Config Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload File to Google Drive": {
      "main": [
        [
          {
            "node": "Log File Details to Google Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process Event and Config Data": {
      "main": [
        [
          {
            "node": "Determine Folder Info",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge Final Parent Folder Data": {
      "main": [
        [
          {
            "node": "Configure Final Parent Folder ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Existing File Type Folder": {
      "main": [
        [
          {
            "node": "Set File Type Folder ID",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Check if Store by File Type is Enabled",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Configure Final Parent Folder ID": {
      "main": [
        [
          {
            "node": "Get File Binary Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log File Details to Google Sheet": {
      "main": [
        [
          {
            "node": "Check Reply Enabled Flag",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if Store by Date is Enabled": {
      "main": [
        [
          {
            "node": "Create Date Folder",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Set Date Folder ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if Store by File Type is Enabled": {
      "main": [
        [
          {
            "node": "Create File Type Folder",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Set File Type Folder ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}