{
  "name": "Compare LINE palm images and log Gemini health insights to Google Sheets",
  "nodes": [
    {
      "id": "8cfdd2db-3d1e-4155-9700-83cc529c54c3",
      "name": "LINE_trigger",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -704,
        -64
      ]
    },
    {
      "id": "5aa86fd1-9c40-4be4-99fc-c2c70d389e90",
      "name": "config",
      "type": "n8n-nodes-base.set",
      "position": [
        -544,
        -64
      ]
    },
    {
      "id": "2fb65e3e-6ac1-4aa3-80d6-009eb3337720",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1664,
        -96
      ]
    },
    {
      "id": "26f6e2ca-cf26-4a05-9bf4-db10d62b031b",
      "name": "PIC_check",
      "type": "n8n-nodes-base.if",
      "position": [
        -416,
        -64
      ]
    },
    {
      "id": "717cd96c-d1c9-4fce-8fb7-1f2caff2485c",
      "name": "LINE_input",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        0,
        -80
      ]
    },
    {
      "id": "7133bbc4-7897-4f27-b0de-73a6b6239367",
      "name": "LINE_output",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2432,
        112
      ]
    },
    {
      "id": "6d0ef990-ea33-4893-82b6-621555c265b0",
      "name": "Analyze",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        1664,
        -272
      ]
    },
    {
      "id": "c16fcffc-e3b1-4187-99f4-8b29538b72cd",
      "name": "PIC_upload",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        192,
        -80
      ]
    },
    {
      "id": "47706f63-23f3-4cd2-bfae-3fa6b7e8f144",
      "name": "Massege_check",
      "type": "n8n-nodes-base.code",
      "position": [
        2080,
        112
      ]
    },
    {
      "id": "ae482352-c0a5-4f02-bcec-30508d187911",
      "name": "DATA_upload",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2256,
        112
      ]
    },
    {
      "id": "44c5a80b-40b4-42f8-a742-d9bbd11f453d",
      "name": "PIC_Search",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        992,
        -96
      ]
    },
    {
      "id": "39cd4459-452f-4f49-aad8-4be255055198",
      "name": "DATA_download",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        320,
        -80
      ]
    },
    {
      "id": "f90adbd0-7f90-446c-ad04-70d61736b49e",
      "name": "Get latest DATA",
      "type": "n8n-nodes-base.code",
      "position": [
        832,
        -96
      ]
    },
    {
      "id": "277dd2f1-dbd9-48e8-9ca2-326f6bd48744",
      "name": "Check Previous Record Exists",
      "type": "n8n-nodes-base.if",
      "position": [
        656,
        -80
      ]
    },
    {
      "id": "14486f32-d6ab-43fd-8fa8-fb26a3ac3ab4",
      "name": "Google Gemini Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1536,
        320
      ]
    },
    {
      "id": "b975d90a-a57e-456f-9cb6-12d0f9ad4be0",
      "name": "First_Analyze",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        1536,
        112
      ]
    },
    {
      "id": "143ac698-ee26-46e9-964b-f2f7b5dd915e",
      "name": "Reply_Text_Instructions",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        0,
        96
      ]
    },
    {
      "id": "dffb7343-031a-4cd9-b940-d0b413587f00",
      "name": "DATA_counting",
      "type": "n8n-nodes-base.code",
      "position": [
        448,
        -80
      ]
    },
    {
      "id": "7200479b-2697-4d96-941a-660a89b46053",
      "name": "Validate Image Pair",
      "type": "n8n-nodes-base.merge",
      "position": [
        1216,
        -272
      ]
    },
    {
      "id": "f468a6a2-1465-41a7-91b6-99ec4d6dfb56",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1296,
        -496
      ],
      "parameters": {
        "width": 528,
        "height": 880,
        "content": "## AI Palm Health Tracker – Overview\n\nThis workflow receives palm images sent via LINE and provides AI-generated health insights.\n\n## Step-by-step process:\n1.User sends a palm image via LINE\n2.Webhook"
      }
    },
    {
      "id": "1d9aebf0-e553-4536-9c54-c47eeeabcb6e",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -720,
        -400
      ],
      "parameters": {
        "width": 864,
        "height": 672,
        "content": "## LINE Webhook Trigger\n\nThis workflow is triggered via the LINE Messaging API webhook.\nIt receives palm images submitted by users and performs AI-based health analysis.\n\nIf the message type is not \"i"
      }
    },
    {
      "id": "983655f1-4708-44d6-85e9-0d0f717c806d",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        160,
        -464
      ],
      "parameters": {
        "width": 416,
        "height": 544,
        "content": "## Image Storage Layer\n\nUploaded images are saved to Google Drive for historical comparison. Next, data stored in Google Sheets is retrieved.\n\nThe stored data includes:\n* Timestamp\n* Drive File ID\n* P"
      }
    },
    {
      "id": "cf8f6a70-ebe1-45b5-a6fa-5b85b12689fe",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        592,
        -480
      ],
      "parameters": {
        "width": 528,
        "height": 560,
        "content": "## Historical Record Retrieval Logic\n\nThe workflow checks if previous palm records exist.\n\nIf no previous record:\n→ Execute First-Time Palm Analysis\n\nIf previous record exists:\n→ Retrieve the most rec"
      }
    },
    {
      "id": "c3f26bb0-913c-4329-beda-6df43ab4cedc",
      "name": "image_counting",
      "type": "n8n-nodes-base.code",
      "position": [
        1424,
        -272
      ]
    },
    {
      "id": "9f132b8a-b21f-4075-bcdf-178cc0c2c03b",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1136,
        -560
      ],
      "parameters": {
        "width": 768,
        "height": 608,
        "content": "## AI Comparison Analysis\n\nGoogle Gemini Vision model performs comparative analysis\nbetween current and previous palm images.\n\nThe model:\n- Detects palm presence\n- Compares lines, dryness, and color t"
      }
    },
    {
      "id": "0c76414f-5888-4582-a211-62fc03746c4d",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        976,
        96
      ],
      "parameters": {
        "width": 864,
        "height": 384,
        "content": "## First-Time Palm Fortune Analysis\n\nIf this is the user's first submission,\nthe workflow performs a standalone palm reading.\n\nOutputs:\n- Life Line Score\n- Heart Line Score\n- Head Line Score\n- Fate Li"
      }
    },
    {
      "id": "32d3abe3-9536-43ce-9ba6-28c357e6652e",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1920,
        -192
      ],
      "parameters": {
        "width": 736,
        "height": 448,
        "content": "## Health Log Recording\n\nAll AI outputs are appended to Google Sheets.\n\nThis enables:\n\n* Progress tracking\n* Data auditing\n* User history management\n* Future analytics expansion\n\nThe message part of t"
      }
    }
  ],
  "connections": {
    "config": {
      "main": [
        [
          {
            "node": "PIC_check",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analyze": {
      "main": [
        [
          {
            "node": "Massege_check",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "PIC_check": {
      "main": [
        [
          {
            "node": "LINE_input",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Reply_Text_Instructions",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "LINE_input": {
      "main": [
        [
          {
            "node": "PIC_upload",
            "type": "main",
            "index": 0
          },
          {
            "node": "Validate Image Pair",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "PIC_Search": {
      "main": [
        [
          {
            "node": "Validate Image Pair",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "PIC_upload": {
      "main": [
        [
          {
            "node": "DATA_download",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "DATA_upload": {
      "main": [
        [
          {
            "node": "LINE_output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "LINE_trigger": {
      "main": [
        [
          {
            "node": "config",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "DATA_counting": {
      "main": [
        [
          {
            "node": "Check Previous Record Exists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "DATA_download": {
      "main": [
        [
          {
            "node": "DATA_counting",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "First_Analyze": {
      "main": [
        [
          {
            "node": "Massege_check",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Massege_check": {
      "main": [
        [
          {
            "node": "DATA_upload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "image_counting": {
      "main": [
        [
          {
            "node": "Analyze",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get latest DATA": {
      "main": [
        [
          {
            "node": "PIC_Search",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate Image Pair": {
      "main": [
        [
          {
            "node": "image_counting",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Analyze",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "First_Analyze",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Check Previous Record Exists": {
      "main": [
        [
          {
            "node": "Get latest DATA",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "First_Analyze",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}