{
  "name": "LINE AI\u8cea\u554f\u7bb1 v1",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "line-ai-question-box",
        "options": {}
      },
      "id": "7d4bfdfd-02bc-4452-b9f4-74238b5f66e9",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        -688,
        608
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "c6d4d6fb-2f43-4e6c-87bc-0a545c6e71b6",
              "name": "replyToken",
              "type": "string",
              "value": "={{ $json.body.events[0].replyToken }}"
            },
            {
              "id": "de65afae-7f86-48e8-a7dd-9a49ff6b3894",
              "name": "messageText",
              "type": "string",
              "value": "={{ $json.body.events[0].message.text }}"
            },
            {
              "id": "ed888f49-147b-41ed-8476-61d8a86b3021",
              "name": "userId",
              "type": "string",
              "value": "={{ $json.body.events[0].source.userId }}"
            }
          ]
        },
        "options": {}
      },
      "id": "17b67eeb-964d-4ee7-9464-65a8f7ee88f5",
      "name": "Extract LINE Data",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -480,
        608
      ]
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "af56c80d-7b7a-4a9f-a150-2fa4db84c56a",
                    "leftValue": "={{ $json.messageText }}",
                    "rightValue": "AI\u8cea\u554f\u7bb1",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "AI\u8cea\u554f\u7bb1"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "cd6f87d4-3b24-4f55-8816-1211f6076ecc",
                    "leftValue": "={{ $json.messageText }}",
                    "rightValue": "AI\u8a3a\u65ad",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "AI\u8a3a\u65ad"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "16d20f2c-c5c3-4fae-9d30-fa1c409e43e2",
                    "leftValue": "={{ $json.messageText }}",
                    "rightValue": "\u30d7\u30ed\u30f3\u30d7\u30c8",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "\u30d7\u30ed\u30f3\u30d7\u30c8"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "eb8a8846-8a9d-45db-adad-4e648c817379",
                    "leftValue": "={{ $json.messageText }}",
                    "rightValue": "AI\u30eb\u30fc\u30eb",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "AI\u30eb\u30fc\u30eb"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "525ca88f-87f3-4052-869b-57acd1368522",
                    "leftValue": "={{ $json.messageText }}",
                    "rightValue": "\u4eca\u9031\u307e\u3068\u3081",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "\u4eca\u9031\u307e\u3068\u3081"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "8794afe0-7b8c-4e75-ba9f-f64e72de408c",
                    "leftValue": "={{ $json.messageText }}",
                    "rightValue": "\u304a\u77e5\u3089\u305b",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "\u304a\u77e5\u3089\u305b"
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra"
        }
      },
      "id": "b3b7eb5f-46df-47ac-88bb-985f56b43f5c",
      "name": "Keyword Switch",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        -240,
        608
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "585c3b65-424d-4ccd-9810-28629a3b2522",
              "name": "replyText",
              "type": "string",
              "value": "AI\u306b\u3064\u3044\u3066\u5206\u304b\u3089\u306a\u3044\u3053\u3068\u3092\u3001\u3053\u306eLINE\u306b\u305d\u306e\u307e\u307e\u9001\u3063\u3066\u304f\u3060\u3055\u3044\u3002"
            }
          ]
        },
        "options": {}
      },
      "id": "fda61bb8-64b0-4604-b1c6-c1d658b58341",
      "name": "Reply - AI\u8cea\u554f\u7bb1",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        48,
        48
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "d851c075-dd50-46b4-87b2-554d21d44cdc",
              "name": "replyText",
              "type": "string",
              "value": "AI\u5c0e\u51655\u5206\u8a3a\u65ad\u306f\u305f\u3060\u3044\u307e\u6e96\u5099\u4e2d\u3067\u3059\u3002\u307e\u305a\u306fAI\u306b\u3064\u3044\u3066\u6c17\u306b\u306a\u308b\u3053\u3068\u3092\u3001\u3053\u306eLINE\u306b\u9001\u3063\u3066\u304f\u3060\u3055\u3044\u3002"
            }
          ]
        },
        "options": {}
      },
      "id": "0fd96345-6558-4c76-9be6-0554f26c07bf",
      "name": "Reply - AI\u8a3a\u65ad",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        48,
        192
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "f77233ac-c05e-4954-9b56-91f59aee9807",
              "name": "replyText",
              "type": "string",
              "value": "\u793e\u9577\u5411\u3051\u30d7\u30ed\u30f3\u30d7\u30c8\u96c6\u306f\u305f\u3060\u3044\u307e\u6e96\u5099\u4e2d\u3067\u3059\u3002\u6e96\u5099\u304c\u3067\u304d\u6b21\u7b2c\u3001\u3053\u306eLINE\u3067\u304a\u77e5\u3089\u305b\u3057\u307e\u3059\u3002"
            }
          ]
        },
        "options": {}
      },
      "id": "b1154496-76bd-49e8-988e-4c64eaee335a",
      "name": "Reply - \u30d7\u30ed\u30f3\u30d7\u30c8",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        48,
        336
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "68f1b09d-526e-42b8-a05c-36e02b8342fe",
              "name": "replyText",
              "type": "string",
              "value": "AI\u5229\u7528\u30eb\u30fc\u30eb\u3072\u306a\u5f62\u306f\u305f\u3060\u3044\u307e\u6e96\u5099\u4e2d\u3067\u3059\u3002\u793e\u54e1\u306bAI\u3092\u4f7f\u308f\u305b\u308b\u524d\u306e\u6ce8\u610f\u70b9\u304b\u3089\u304a\u5c4a\u3051\u4e88\u5b9a\u3067\u3059\u3002"
            }
          ]
        },
        "options": {}
      },
      "id": "7dd7088a-3386-43cc-b5df-246e33e1cf60",
      "name": "Reply - AI\u30eb\u30fc\u30eb",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        48,
        480
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "aee1cd00-578b-4525-9191-e0996ae9bb24",
              "name": "replyText",
              "type": "string",
              "value": "\u4eca\u9031\u306e\u307e\u3068\u3081\u306f\u305f\u3060\u3044\u307e\u6e96\u5099\u4e2d\u3067\u3059\u3002\u914d\u4fe1\u958b\u59cb\u5f8c\u306b\u3053\u3061\u3089\u304b\u3089\u78ba\u8a8d\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002"
            }
          ]
        },
        "options": {}
      },
      "id": "e35af00a-35a2-4a58-848c-9804b5afc30e",
      "name": "Reply - \u4eca\u9031\u307e\u3068\u3081",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        48,
        608
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "9020b20b-9671-4d45-9135-b47a5d30b981",
              "name": "replyText",
              "type": "string",
              "value": "\u304a\u77e5\u3089\u305b\u306f\u305f\u3060\u3044\u307e\u6e96\u5099\u4e2d\u3067\u3059\u3002\u7121\u6599\u52c9\u5f37\u4f1a\u3084\u66f4\u65b0\u60c5\u5831\u306f\u3053\u3061\u3089\u3067\u3054\u6848\u5185\u3057\u307e\u3059\u3002"
            }
          ]
        },
        "options": {}
      },
      "id": "e3a63f5c-bae5-4a18-b477-3393f22d23b7",
      "name": "Reply - \u304a\u77e5\u3089\u305b",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        48,
        752
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "0a390065-47c6-4b7d-b8cb-0f3390da86a3",
              "name": "systemPrompt",
              "type": "string",
              "value": "\u3042\u306a\u305f\u306f\u300c\u6210\u76f8AI\u671d\u6d3b\u30e9\u30dc\u300d\u306eAI\u8cea\u554f\u7bb1\u3067\u3059\u3002\n\u76f8\u624b\u306fAI\u521d\u5fc3\u8005\u306e\u7d4c\u55b6\u8005\u3067\u3059\u3002\n\u96e3\u3057\u3044\u5c02\u9580\u7528\u8a9e\u3092\u907f\u3051\u3066\u3001\u77ed\u304f\u5206\u304b\u308a\u3084\u3059\u304f\u56de\u7b54\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n\n\u30eb\u30fc\u30eb\uff1a\n- 120\u6587\u5b57\u4ee5\u5185\n- 2\u301c3\u6587\u307e\u3067\n- \u307e\u305a\u7d50\u8ad6\u304b\u3089\n- \u4e2d\u5c0f\u4f01\u696d\u3067\u306e\u4f7f\u3044\u65b9\u30921\u3064\u3060\u3051\u5165\u308c\u308b\n- \u904e\u5ea6\u306a\u55b6\u696d\u6587\u306b\u3057\u306a\u3044\n- \u5206\u304b\u3089\u306a\u3044\u3053\u3068\u306f\u65ad\u5b9a\u3057\u306a\u3044\n- \u6700\u5f8c\u306e\u5b9a\u578b\u6587\u306f\u6bce\u56de\u5165\u308c\u306a\u3044\n- \u8a73\u7d30\u304c\u5fc5\u8981\u306a\u5834\u5408\u3060\u3051\u300c\u5fc5\u8981\u306a\u3089\u5177\u4f53\u7684\u306b\u805e\u3044\u3066\u304f\u3060\u3055\u3044\u3002\u300d\u3068\u6dfb\u3048\u308b"
            },
            {
              "id": "3ebfcb60-30e8-4b5a-a9d4-b62209ad2f36",
              "name": "userMessage",
              "type": "string",
              "value": "={{ $json.messageText }}"
            }
          ]
        },
        "options": {}
      },
      "id": "ae32380d-19a9-4419-b694-a29f3816dcb6",
      "name": "Prepare OpenAI Prompt",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        48,
        912
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.openai.com/v1/chat/completions",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "openAiApi",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ model: 'gpt-4o-mini', messages: [ { role: 'system', content: $json.systemPrompt }, { role: 'user', content: $json.userMessage } ] }) }}",
        "options": {}
      },
      "id": "53eaf71b-c243-42c7-9704-97660526e1b1",
      "name": "Call OpenAI",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        288,
        912
      ],
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "e26f064c-ebe1-4544-9d8d-fa3e8ebed183",
              "name": "replyText",
              "type": "string",
              "value": "={{ $json.choices[0].message.content }}"
            }
          ]
        },
        "options": {}
      },
      "id": "c981da64-119b-4bb6-972d-18c021db4698",
      "name": "Format AI Reply",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        528,
        848
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "5ee94f8c-7067-4600-8315-a8dd59d24159",
              "name": "replyText",
              "type": "string",
              "value": "\u3059\u307f\u307e\u305b\u3093\u3001\u305f\u3060\u3044\u307eAI\u56de\u7b54\u306e\u6e96\u5099\u4e2d\u3067\u3059\u3002\u5c11\u3057\u6642\u9593\u3092\u304a\u3044\u3066\u518d\u5ea6\u304a\u8a66\u3057\u304f\u3060\u3055\u3044\u3002"
            }
          ]
        },
        "options": {}
      },
      "id": "0a3d63f0-ada3-4c9b-95f3-a700a52c86c7",
      "name": "Format Error Reply",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        528,
        992
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.line.me/v2/bot/message/reply",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ replyToken: $('Extract LINE Data').item.json.replyToken, messages: [ { type: 'text', text: $json.replyText } ] }) }}",
        "options": {}
      },
      "id": "1c0c48b5-a432-40f6-8d82-024c5f83dc02",
      "name": "Send LINE Reply",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        768,
        608
      ],
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Extract LINE Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract LINE Data": {
      "main": [
        [
          {
            "node": "Keyword Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Keyword Switch": {
      "main": [
        [
          {
            "node": "Reply - AI\u8cea\u554f\u7bb1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Reply - AI\u8a3a\u65ad",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Reply - \u30d7\u30ed\u30f3\u30d7\u30c8",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Reply - AI\u30eb\u30fc\u30eb",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Reply - \u4eca\u9031\u307e\u3068\u3081",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Reply - \u304a\u77e5\u3089\u305b",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Prepare OpenAI Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Reply - AI\u8cea\u554f\u7bb1": {
      "main": [
        [
          {
            "node": "Send LINE Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Reply - AI\u8a3a\u65ad": {
      "main": [
        [
          {
            "node": "Send LINE Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Reply - \u30d7\u30ed\u30f3\u30d7\u30c8": {
      "main": [
        [
          {
            "node": "Send LINE Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Reply - AI\u30eb\u30fc\u30eb": {
      "main": [
        [
          {
            "node": "Send LINE Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Reply - \u4eca\u9031\u307e\u3068\u3081": {
      "main": [
        [
          {
            "node": "Send LINE Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Reply - \u304a\u77e5\u3089\u305b": {
      "main": [
        [
          {
            "node": "Send LINE Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare OpenAI Prompt": {
      "main": [
        [
          {
            "node": "Call OpenAI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Call OpenAI": {
      "main": [
        [
          {
            "node": "Format AI Reply",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Format Error Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format AI Reply": {
      "main": [
        [
          {
            "node": "Send LINE Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Error Reply": {
      "main": [
        [
          {
            "node": "Send LINE Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate",
    "availableInMCP": false,
    "timeSavedMode": "fixed",
    "callerPolicy": "workflowsFromSameOwner"
  },
  "versionId": "4d0a7ce7-d9fc-4b8d-b2d3-f43e453e8f71",
  "nodeGroups": [],
  "id": "1a5EcuQh2BAJync1",
  "tags": []
}