{
  "name": "Momentry Video Search",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "video-search",
        "responseMode": "lastNode",
        "options": {}
      },
      "id": "webhook-trigger",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        250,
        300
      ],
      "webhookId": "video-search"
    },
    {
      "parameters": {
        "url": "http://localhost:3002/api/v1/n8n/search",
        "method": "POST",
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "query",
              "value": "={{ $json.body }}"
            },
            {
              "name": "limit",
              "value": 5
            }
          ]
        },
        "options": {
          "headers": {
            "Content-Type": "application/json",
            "X-API-Key": "demo_api_key_12345"
          }
        }
      },
      "id": "http-request-search",
      "name": "搜尋 Momentry",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 3,
      "position": [
        500,
        300
      ]
    },
    {
      "parameters": {
        "jsCode": "const hits = $input.first().json.hits;\n\nif (!hits || hits.length === 0) {\n  return {\n    json: {\n      message: '找不到相關結果',\n      query: $input.first().json.query\n    }\n  };\n}\n\nconst results = hits.map((hit, index) => {\n  return {\n    number: index + 1,\n    text: hit.text,\n    start: hit.start,\n    end: hit.end,\n    score: Math.round(hit.score * 100) + '%',\n    video_title: hit.title,\n    file_path: hit.file_path\n  };\n});\n\nreturn {\n  json: {\n    query: $input.first().json.query,\n    count: $input.first().json.count,\n    results: results\n  }\n};"
      },
      "id": "code-process",
      "name": "處理結果",
      "type": "n8n-nodes-base.code",
      "typeVersion": 1,
      "position": [
        750,
        300
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.telegram.org/bot{{ $env.TELEGRAM_BOT_TOKEN }}/sendMessage",
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "chat_id",
              "value": "={{ $json.chat_id }}"
            },
            {
              "name": "text",
              "value": "=🎬 搜尋結果: \"{{ $json.query }}\"\n\n{{ $json.results.map(r => r.number + '️⃣ \"' + r.text.substring(0, 50) + '...\"\n⏱ ' + r.start + 's - ' + r.end + 's\n📊 相關度: ' + r.score).join('\n\n') }}"
            }
          ]
        },
        "options": {}
      },
      "id": "telegram-send",
      "name": "Telegram 通知",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 3,
      "position": [
        1000,
        300
      ],
      "continueOnFail": true
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "搜尋 Momentry",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "搜尋 Momentry": {
      "main": [
        [
          {
            "node": "處理結果",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "處理結果": {
      "main": [
        [
          {
            "node": "Telegram 通知",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {},
  "id": "momentry-video-search",
  "versionId": "1",
  "createdAt": "2026-03-23T00:00:00.000Z",
  "updatedAt": "2026-03-23T00:00:00.000Z"
}