{
  "name": "[\uae08\uc735] AI \uc778\ubcf4\uc774\uc2a4 \uc790\ub3d9 \ucc98\ub9ac - \uc774\uba54\uc77c \uc218\uc2e0",
  "nodes": [
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "simple": false,
        "filters": {
          "subject": "\uc778\ubcf4\uc774\uc2a4|invoice|\uccad\uad6c\uc11c|\uc138\uae08\uacc4\uc0b0\uc11c"
        },
        "options": {}
      },
      "id": "gmail-trigger-node",
      "name": "\uc778\ubcf4\uc774\uc2a4 \uc774\uba54\uc77c \uc218\uc2e0",
      "type": "n8n-nodes-base.gmailTrigger",
      "typeVersion": 1,
      "position": [
        250,
        300
      ],
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// \uc774\uba54\uc77c \ubcf8\ubb38\uc5d0\uc11c \uc778\ubcf4\uc774\uc2a4 \uad00\ub828 \uc815\ubcf4 \ucd94\ucd9c\nconst email = $input.item.json;\n\nreturn {\n  json: {\n    subject: email.subject || '',\n    from: email.from || '',\n    body: email.textPlain || email.textHtml || '',\n    date: email.date || new Date().toISOString()\n  }\n};"
      },
      "id": "code-extract-node",
      "name": "\uc774\uba54\uc77c \ubcf8\ubb38 \ucd94\ucd9c",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        450,
        300
      ]
    },
    {
      "parameters": {
        "resource": "text",
        "operation": "message",
        "modelId": "gpt-4o-mini",
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "\ub2f9\uc2e0\uc740 \uc778\ubcf4\uc774\uc2a4 \ud30c\uc2f1 \uc804\ubb38\uac00\uc785\ub2c8\ub2e4. \uc774\uba54\uc77c \ub0b4\uc6a9\uc5d0\uc11c \uc778\ubcf4\uc774\uc2a4 \uc815\ubcf4\ub97c \ucd94\ucd9c\ud558\uc5ec \ubc18\ub4dc\uc2dc \ub2e4\uc74c JSON \ud615\uc2dd\uc73c\ub85c \uc751\ub2f5\ud558\uc138\uc694:\n{\"vendor\": \"\uc5c5\uccb4\uba85\", \"amount\": \uae08\uc561(\uc22b\uc790\ub9cc), \"dueDate\": \"\ub0a9\uae30\uc77c(YYYY-MM-DD)\", \"items\": \"\ud488\ubaa9 \uc694\uc57d\"}\n\n\uc815\ubcf4\ub97c \ucc3e\uc744 \uc218 \uc5c6\ub294 \ud544\ub4dc\ub294 null\ub85c \ud45c\uc2dc\ud558\uc138\uc694. \uae08\uc561\uc740 \ubc18\ub4dc\uc2dc \uc22b\uc790\ub9cc \uc785\ub825\ud558\uc138\uc694."
            },
            {
              "role": "user",
              "content": "=\uc81c\ubaa9: {{ $json.subject }}\n\ubc1c\uc2e0\uc790: {{ $json.from }}\n\n\ubcf8\ubb38:\n{{ $json.body }}"
            }
          ]
        },
        "options": {
          "temperature": 0.2
        }
      },
      "id": "openai-node",
      "name": "AI \uc778\ubcf4\uc774\uc2a4 \ud30c\uc2f1",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.3,
      "position": [
        650,
        300
      ],
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// AI \uc751\ub2f5 JSON \ud30c\uc2f1 \ubc0f \uae30\ubcf8\uac12 \ucc98\ub9ac\nconst aiResponse = $input.item.json.message?.content || '{}';\nlet parsed;\n\ntry {\n  parsed = JSON.parse(aiResponse);\n} catch (e) {\n  parsed = { vendor: '\ud30c\uc2f1 \uc2e4\ud328', amount: 0, dueDate: null, items: '\ud655\uc778 \ud544\uc694' };\n}\n\nconst emailData = $('\uc774\uba54\uc77c \ubcf8\ubb38 \ucd94\ucd9c').item.json;\n\nreturn {\n  json: {\n    date: new Date().toISOString().slice(0, 10),\n    vendor: parsed.vendor || '\ubbf8\ud655\uc778',\n    amount: parsed.amount || 0,\n    dueDate: parsed.dueDate || '\ubbf8\uc815',\n    items: parsed.items || '\ud655\uc778 \ud544\uc694',\n    emailSubject: emailData.subject,\n    emailFrom: emailData.from\n  }\n};"
      },
      "id": "code-parse-node",
      "name": "\ud30c\uc2f1 \uacb0\uacfc \uc815\ub9ac",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        850,
        300
      ]
    },
    {
      "parameters": {
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "value": "placeholder-spreadsheet-id",
          "mode": "id",
          "cachedResultName": "\uc778\ubcf4\uc774\uc2a4 \uad00\ub9ac"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "id",
          "cachedResultName": "Sheet1"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "\ub0a0\uc9dc": "={{ $json.date }}",
            "\uc5c5\uccb4\uba85": "={{ $json.vendor }}",
            "\uae08\uc561": "={{ $json.amount }}",
            "\ub0a9\uae30\uc77c": "={{ $json.dueDate }}",
            "\ud488\ubaa9": "={{ $json.items }}"
          },
          "matchingColumns": [],
          "schema": []
        },
        "options": {
          "cellFormat": "USER_ENTERED",
          "useAppend": true
        }
      },
      "id": "sheets-node",
      "name": "\uad6c\uae00 \uc2dc\ud2b8 \uae30\ub85d",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.4,
      "position": [
        1050,
        300
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": ""
          },
          "conditions": [
            {
              "id": "1",
              "leftValue": "={{ $json.amount }}",
              "rightValue": 1000000,
              "operator": {
                "type": "number",
                "operation": "gt"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "if-node",
      "name": "\uace0\uc561 \uc778\ubcf4\uc774\uc2a4?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        1250,
        300
      ]
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "value": "C12345FINANCE",
          "mode": "id"
        },
        "text": "=:rotating_light: \uace0\uc561 \uc778\ubcf4\uc774\uc2a4 \uc54c\ub9bc\n\n*\uc5c5\uccb4\uba85:* {{ $json.vendor }}\n*\uae08\uc561:* {{ Number($json.amount).toLocaleString() }}\uc6d0\n*\ub0a9\uae30\uc77c:* {{ $json.dueDate }}\n*\ud488\ubaa9:* {{ $json.items }}\n*\uc218\uc2e0\uc77c:* {{ $json.date }}",
        "otherOptions": {}
      },
      "id": "slack-node",
      "name": "\uace0\uc561 \uc54c\ub9bc",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.2,
      "position": [
        1450,
        300
      ],
      "credentials": {
        "slackOAuth2Api": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "\uc778\ubcf4\uc774\uc2a4 \uc774\uba54\uc77c \uc218\uc2e0": {
      "main": [
        [
          {
            "node": "\uc774\uba54\uc77c \ubcf8\ubb38 \ucd94\ucd9c",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\uc774\uba54\uc77c \ubcf8\ubb38 \ucd94\ucd9c": {
      "main": [
        [
          {
            "node": "AI \uc778\ubcf4\uc774\uc2a4 \ud30c\uc2f1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI \uc778\ubcf4\uc774\uc2a4 \ud30c\uc2f1": {
      "main": [
        [
          {
            "node": "\ud30c\uc2f1 \uacb0\uacfc \uc815\ub9ac",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\ud30c\uc2f1 \uacb0\uacfc \uc815\ub9ac": {
      "main": [
        [
          {
            "node": "\uad6c\uae00 \uc2dc\ud2b8 \uae30\ub85d",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\uad6c\uae00 \uc2dc\ud2b8 \uae30\ub85d": {
      "main": [
        [
          {
            "node": "\uace0\uc561 \uc778\ubcf4\uc774\uc2a4?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\uace0\uc561 \uc778\ubcf4\uc774\uc2a4?": {
      "main": [
        [
          {
            "node": "\uace0\uc561 \uc54c\ub9bc",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "saveManualExecutions": true,
    "callerPolicy": "workflowsFromSameOwner",
    "errorWorkflow": "",
    "timezone": "Asia/Seoul",
    "saveExecutionProgress": true,
    "saveDataErrorExecution": "all",
    "saveDataSuccessExecution": "all",
    "executionTimeout": 3600
  },
  "staticData": null,
  "tags": [
    {
      "createdAt": "2026-03-09T00:00:00.000Z",
      "updatedAt": "2026-03-09T00:00:00.000Z",
      "id": "finance",
      "name": "\uae08\uc735"
    },
    {
      "createdAt": "2026-03-09T00:00:00.000Z",
      "updatedAt": "2026-03-09T00:00:00.000Z",
      "id": "ai-automation",
      "name": "AI \uc790\ub3d9\ud654"
    }
  ],
  "triggerCount": 1,
  "updatedAt": "2026-03-09T00:00:00.000Z",
  "versionId": "1"
}