{
  "name": "問い合わせ受付（基本形）",
  "nodes": [
    {
      "name": "問い合わせを受ける",
      "type": "n8n-nodes-base.formTrigger",
      "typeVersion": 2.2,
      "position": [0, 0],
      "parameters": {
        "formTitle": "お問い合わせ",
        "formDescription": "ご用件をお聞かせください。担当者より折り返しご連絡いたします。",
        "formFields": {
          "values": [
            { "fieldLabel": "会社名", "requiredField": true },
            { "fieldLabel": "お名前", "requiredField": true },
            { "fieldLabel": "メールアドレス", "fieldType": "email", "requiredField": true },
            { "fieldLabel": "お問い合わせ内容", "fieldType": "textarea", "requiredField": true }
          ]
        },
        "options": {}
      }
    },
    {
      "name": "内容を判定する",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [220, 0],
      "parameters": {
        "modelId": { "__rl": true, "value": "gpt-4.1-mini", "mode": "list" },
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "あなたは営業事務の担当者です。問い合わせ内容を読み、次の3つを判定してください。\n\n必ず次の JSON だけを返してください。前後に説明文を書かないでください。\n\n{\n  \"summary\": \"内容を1行で要約（40字以内）\",\n  \"urgency\": \"高\" または \"中\" または \"低\",\n  \"reply\": \"最初に返すべき一言（そのまま送れる敬体で、80字以内）\"\n}\n\n緊急度の基準:\n高 = 期限が明示されている、トラブルや不具合の申告、失注の恐れがある\n中 = 具体的な検討段階にあるが期限の明示がない\n低 = 資料請求、一般的な問い合わせ"
            },
            {
              "role": "user",
              "content": "=会社名: {{ $json['会社名'] }}\nお名前: {{ $json['お名前'] }}\n本文:\n{{ $json['お問い合わせ内容'] }}"
            }
          ]
        },
        "jsonOutput": true,
        "options": {}
      }
    },
    {
      "name": "列を整える",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [440, 0],
      "parameters": {
        "mode": "manual",
        "duplicateItem": false,
        "assignments": {
          "assignments": [
            {
              "id": "col-01",
              "name": "受信日時",
              "value": "={{ $now.format('yyyy-MM-dd HH:mm') }}",
              "type": "string"
            },
            {
              "id": "col-02",
              "name": "会社名",
              "value": "={{ $('問い合わせを受ける').item.json['会社名'] }}",
              "type": "string"
            },
            {
              "id": "col-03",
              "name": "お名前",
              "value": "={{ $('問い合わせを受ける').item.json['お名前'] }}",
              "type": "string"
            },
            {
              "id": "col-04",
              "name": "メールアドレス",
              "value": "={{ $('問い合わせを受ける').item.json['メールアドレス'] }}",
              "type": "string"
            },
            {
              "id": "col-05",
              "name": "問い合わせ内容",
              "value": "={{ $('問い合わせを受ける').item.json['お問い合わせ内容'] }}",
              "type": "string"
            },
            {
              "id": "col-06",
              "name": "要約",
              "value": "={{ $json.message.content.summary }}",
              "type": "string"
            },
            {
              "id": "col-07",
              "name": "緊急度",
              "value": "={{ $json.message.content.urgency }}",
              "type": "string"
            },
            {
              "id": "col-08",
              "name": "返す一言",
              "value": "={{ $json.message.content.reply }}",
              "type": "string"
            }
          ]
        },
        "includeOtherFields": false,
        "options": {}
      }
    },
    {
      "name": "シートに追加する",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [660, 0],
      "parameters": {
        "operation": "append",
        "documentId": { "__rl": true, "value": "", "mode": "url" },
        "sheetName": { "__rl": true, "value": "", "mode": "list" },
        "columns": {
          "mappingMode": "autoMapInputData",
          "value": {},
          "matchingColumns": []
        },
        "options": {}
      }
    }
  ],
  "connections": {
    "問い合わせを受ける": { "main": [[{ "node": "内容を判定する", "type": "main", "index": 0 }]] },
    "内容を判定する": { "main": [[{ "node": "列を整える", "type": "main", "index": 0 }]] },
    "列を整える": { "main": [[{ "node": "シートに追加する", "type": "main", "index": 0 }]] }
  },
  "settings": { "executionOrder": "v1" },
  "pinData": {}
}
