{
  "name": "Gmail\u53d7\u4fe1\u30e1\u30fc\u30eb\u51e6\u7406\u30ef\u30fc\u30af\u30d5\u30ed\u30fc",
  "nodes": [
    {
      "parameters": {
        "authentication": "oAuth2",
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "simple": false,
        "filters": {}
      },
      "id": "d4f2c0a1-8b3e-4c5a-9d7f-1e2a3b4c5d6e",
      "name": "Gmail Trigger",
      "type": "n8n-nodes-base.gmailTrigger",
      "typeVersion": 1.2,
      "position": [
        240,
        400
      ]
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "sender",
              "value": "={{ $json.payload.headers.find(h => h.name === 'From').value }}"
            },
            {
              "name": "subject",
              "value": "={{ $json.payload.headers.find(h => h.name === 'Subject').value }}"
            },
            {
              "name": "body",
              "value": "={{ $json.snippet }}"
            },
            {
              "name": "received_time",
              "value": "={{ new Date($json.internalDate * 1).toISOString() }}"
            },
            {
              "name": "sender_clean",
              "value": "={{ $json.payload.headers.find(h => h.name === 'From').value.split('<')[0].trim() }}"
            }
          ]
        },
        "options": {}
      },
      "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "name": "\u30e1\u30fc\u30eb\u60c5\u5831\u62bd\u51fa",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        460,
        400
      ]
    },
    {
      "parameters": {
        "resource": "text",
        "operation": "complete",
        "prompt": "\u4ee5\u4e0b\u306e\u30e1\u30fc\u30eb\u5185\u5bb9\u3092\u8981\u7d04\u3057\u3066\u3001\u4ee5\u4e0b\u306e\u5f62\u5f0f\u3067\u65e5\u672c\u8a9e\u3067\u8fd4\u3057\u3066\u304f\u3060\u3055\u3044\uff1a\n\n\u3010\u8981\u7d04\u3011\n\u30fb[\u7b87\u6761\u66f8\u304d\u3067\u8981\u7d04]\n\n\u3010\u9001\u4fe1\u8005\u3011{{ $json.sender_clean }}\n\u3010\u4ef6\u540d\u3011{{ $json.subject }}\n\u3010\u65e5\u6642\u3011{{ $json.received_time }}\n\u3010\u30b9\u30c6\u30fc\u30bf\u30b9\u3011\u672a\u5bfe\u5fdc\n\u3010\u6b21\u306e\u30a2\u30af\u30b7\u30e7\u30f3\u3011\n\u30fb[\u5fc5\u8981\u306a\u30a2\u30af\u30b7\u30e7\u30f3\u304c\u3042\u308c\u3070\u8a18\u8f09\u3001\u306a\u3051\u308c\u3070\u300c\u306a\u3057\u300d]\n\u3010\u7de0\u5207/\u65e5\u4ed8\u3011\n\u30fb[\u671f\u9650\u3084\u91cd\u8981\u306a\u65e5\u4ed8\u304c\u3042\u308c\u3070\u8a18\u8f09\u3001\u306a\u3051\u308c\u3070\u300c\u306a\u3057\u300d]\n\n\u3010\u30e1\u30fc\u30eb\u672c\u6587\u3011\n{{ $json.body }}",
        "maxTokens": 500,
        "options": {}
      },
      "id": "e1f2a3b4-c5d6-7890-abcd-ef1234567890",
      "name": "OpenAI\u8981\u7d04\u51e6\u7406",
      "type": "n8n-nodes-base.openAi",
      "typeVersion": 1.1,
      "position": [
        680,
        400
      ]
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "summary",
              "value": "={{ $json.data.choices[0].text }}"
            },
            {
              "name": "sender",
              "value": "={{ $('\u30e1\u30fc\u30eb\u60c5\u5831\u62bd\u51fa').item.json.sender }}"
            },
            {
              "name": "sender_clean",
              "value": "={{ $('\u30e1\u30fc\u30eb\u60c5\u5831\u62bd\u51fa').item.json.sender_clean }}"
            },
            {
              "name": "subject",
              "value": "={{ $('\u30e1\u30fc\u30eb\u60c5\u5831\u62bd\u51fa').item.json.subject }}"
            },
            {
              "name": "received_time",
              "value": "={{ $('\u30e1\u30fc\u30eb\u60c5\u5831\u62bd\u51fa').item.json.received_time }}"
            },
            {
              "name": "body",
              "value": "={{ $('\u30e1\u30fc\u30eb\u60c5\u5831\u62bd\u51fa').item.json.body }}"
            }
          ]
        },
        "options": {}
      },
      "id": "f2a3b4c5-d6e7-8901-bcde-f23456789012",
      "name": "\u8981\u7d04\u7d50\u679c\u7d71\u5408",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        900,
        400
      ]
    },
    {
      "parameters": {
        "resource": "document",
        "operation": "update",
        "documentURL": "https://docs.google.com/document/d/YOUR_DOCUMENT_ID/edit",
        "actionsUi": {
          "action": [
            {
              "action": "appendText",
              "text": "\n\n---\n{{ $json.received_time }}\n{{ $json.summary }}\n---"
            }
          ]
        }
      },
      "id": "a3b4c5d6-e7f8-9012-cdef-345678901234",
      "name": "Google Docs\u8ffd\u8a18",
      "type": "n8n-nodes-base.googleDocs",
      "typeVersion": 2,
      "position": [
        1120,
        300
      ]
    },
    {
      "parameters": {
        "resource": "sheet",
        "operation": "appendOrUpdate",
        "documentId": {
          "mode": "id",
          "value": "YOUR_SPREADSHEET_ID"
        },
        "sheetName": {
          "mode": "id",
          "value": "\u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9"
        },
        "columns": {
          "value": {
            "A": "={{ $json.sender_clean }}",
            "B": "={{ $json.received_time }}",
            "C": "={{ $json.summary.split('\u3010\u8981\u7d04\u3011')[1].split('\u3010\u9001\u4fe1\u8005\u3011')[0].trim() }}",
            "D": "\u672a\u5bfe\u5fdc",
            "E": "={{ $json.summary.includes('\u3010\u6b21\u306e\u30a2\u30af\u30b7\u30e7\u30f3\u3011') ? $json.summary.split('\u3010\u6b21\u306e\u30a2\u30af\u30b7\u30e7\u30f3\u3011')[1].split('\u3010\u7de0\u5207/\u65e5\u4ed8\u3011')[0].trim() : '\u306a\u3057' }}",
            "F": "={{ $json.summary.includes('\u3010\u7de0\u5207/\u65e5\u4ed8\u3011') ? $json.summary.split('\u3010\u7de0\u5207/\u65e5\u4ed8\u3011')[1].trim() : '\u306a\u3057' }}",
            "G": "https://docs.google.com/document/d/YOUR_DOCUMENT_ID/edit"
          }
        },
        "options": {
          "cellFormat": "USER_ENTERED"
        }
      },
      "id": "b4c5d6e7-f8a9-0123-defa-456789012345",
      "name": "Google Sheets\u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u66f4\u65b0",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.6,
      "position": [
        1120,
        500
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": false,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "condition1",
              "leftValue": "={{ $json.summary }}",
              "rightValue": "\u671f\u9650|\u7de0\u5207|deadline|due|until|\u307e\u3067",
              "operator": {
                "type": "string",
                "operation": "regex"
              }
            }
          ],
          "combinator": "or"
        },
        "options": {}
      },
      "id": "c5d6e7f8-a9b0-1234-efab-567890123456",
      "name": "\u671f\u9650\u30fb\u30a2\u30af\u30b7\u30e7\u30f3\u691c\u51fa",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        1340,
        400
      ]
    },
    {
      "parameters": {
        "resource": "event",
        "operation": "create",
        "calendar": {
          "mode": "id",
          "value": "primary"
        },
        "additionalFields": {
          "start": "={{ $now.plus(1, 'day') }}",
          "end": "={{ $now.plus(1, 'day').plus(1, 'hour') }}",
          "summary": "{{ $json.subject }} - \u30d5\u30a9\u30ed\u30fc\u30a2\u30c3\u30d7",
          "description": "\u9001\u4fe1\u8005: {{ $json.sender_clean }}\n\u8981\u7d04: {{ $json.summary }}"
        }
      },
      "id": "d6e7f8a9-b0c1-2345-fabc-678901234567",
      "name": "Google Calendar\u4e88\u5b9a\u8ffd\u52a0",
      "type": "n8n-nodes-base.googleCalendar",
      "typeVersion": 1.3,
      "position": [
        1560,
        300
      ]
    },
    {
      "parameters": {
        "resource": "task",
        "operation": "create",
        "task": "@default",
        "title": "{{ $json.subject }} - \u5bfe\u5fdc",
        "additionalFields": {
          "notes": "\u9001\u4fe1\u8005: {{ $json.sender_clean }}\n\u53d7\u4fe1\u6642\u523b: {{ $json.received_time }}\n\u8981\u7d04: {{ $json.summary }}"
        }
      },
      "id": "e7f8a9b0-c1d2-3456-gbcd-789012345678",
      "name": "Google Tasks\u8ffd\u52a0",
      "type": "n8n-nodes-base.googleTasks",
      "typeVersion": 1,
      "position": [
        1560,
        500
      ]
    },
    {
      "parameters": {
        "content": "\u2705 \u30e1\u30fc\u30eb\u51e6\u7406\u5b8c\u4e86\n\n\u9001\u4fe1\u8005: {{ $json.sender_clean }}\n\u4ef6\u540d: {{ $json.subject }}\n\u53d7\u4fe1\u6642\u523b: {{ $json.received_time }}\n\n\u2713 \u8981\u7d04\u5b8c\u4e86\n\u2713 Docs\u8ffd\u8a18\u5b8c\u4e86\n\u2713 Sheets\u66f4\u65b0\u5b8c\u4e86",
        "height": 220,
        "width": 350,
        "color": 5
      },
      "id": "f8a9b0c1-d2e3-4567-hcde-890123456789",
      "name": "\u51e6\u7406\u5b8c\u4e86\u901a\u77e5",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1340,
        600
      ]
    }
  ],
  "connections": {
    "Gmail Trigger": {
      "main": [
        [
          {
            "node": "\u30e1\u30fc\u30eb\u60c5\u5831\u62bd\u51fa",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u30e1\u30fc\u30eb\u60c5\u5831\u62bd\u51fa": {
      "main": [
        [
          {
            "node": "OpenAI\u8981\u7d04\u51e6\u7406",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI\u8981\u7d04\u51e6\u7406": {
      "main": [
        [
          {
            "node": "\u8981\u7d04\u7d50\u679c\u7d71\u5408",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u8981\u7d04\u7d50\u679c\u7d71\u5408": {
      "main": [
        [
          {
            "node": "Google Docs\u8ffd\u8a18",
            "type": "main",
            "index": 0
          },
          {
            "node": "Google Sheets\u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u66f4\u65b0",
            "type": "main",
            "index": 0
          },
          {
            "node": "\u671f\u9650\u30fb\u30a2\u30af\u30b7\u30e7\u30f3\u691c\u51fa",
            "type": "main",
            "index": 0
          },
          {
            "node": "\u51e6\u7406\u5b8c\u4e86\u901a\u77e5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u671f\u9650\u30fb\u30a2\u30af\u30b7\u30e7\u30f3\u691c\u51fa": {
      "main": [
        [
          {
            "node": "Google Calendar\u4e88\u5b9a\u8ffd\u52a0",
            "type": "main",
            "index": 0
          },
          {
            "node": "Google Tasks\u8ffd\u52a0",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "tags": [
    {
      "createdAt": "2024-09-29T08:30:00.000Z",
      "updatedAt": "2024-09-29T08:30:00.000Z",
      "id": "gmail-automation",
      "name": "Gmail\u81ea\u52d5\u5316"
    }
  ],
  "triggerCount": 1,
  "updatedAt": "2024-09-29T08:30:00.000Z",
  "versionId": "1"
}