{
  "name": "Tana Exa Search",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "REPLACE_WITH_YOUR_WEBHOOK_PATH",
        "responseMode": "responseNode",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        -544,
        -240
      ],
      "name": "Webhook"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.exa.ai/search",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"query\": \"={{$json.body.query}}\",\n  \"type\": \"auto\",\n  \"numResults\": 10,\n  \"text\": true,\n  \"summary\": true\n}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.3,
      "position": [
        -336,
        -240
      ],
      "name": "Exa Search",
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// 1. \u4ece Webhook \u8282\u70b9\u62ff query\nconst webhookOutput = $node[\"Webhook\"].json;\nconst query = webhookOutput.body?.query || \"(no query)\";\n\n// 2. \u4ece Exa Search \u8282\u70b9\uff08\u5f53\u524d\u8f93\u5165\uff09\u62ff\u7ed3\u679c\nconst exaData = items[0].json;\nconst results = Array.isArray(exaData.results) ? exaData.results : [];\n\n// 3. \u751f\u6210\u5d4c\u5957 <ul><li> \u7ed3\u6784\u7684 HTML\nlet html = \"\";\nhtml += `<h2>Exa \u641c\u7d22\u7ed3\u679c\uff1a${query}</h2>`;\nhtml += \"<ul>\";\n\nresults.slice(0, 10).forEach((r, idx) => {\n  const title =\n    (r.title && r.title.trim() !== \"\" ? r.title : null) ||\n    r.url ||\n    `Result ${idx + 1}`;\n\n  html += `<li>${idx + 1}. ${title}<ul>`;\n\n  if (r.url) {\n    html += `<li>${r.url}</li>`;\n  }\n  if (r.publishedDate) {\n    html += `<li>Published: ${r.publishedDate}</li>`;\n  }\n  if (r.author) {\n    html += `<li>Author: ${r.author}</li>`;\n  }\n\n  html += `</ul></li>`;\n});\n\nhtml += \"</ul>\";\n\n// 4. \u8fd4\u56de\u7ed9 Respond to Webhook\nreturn [\n  {\n    json: {\n      body: html\n    }\n  }\n];\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -128,
        -240
      ],
      "name": "Code in JavaScript"
    },
    {
      "parameters": {
        "respondWith": "text",
        "responseBody": "={{ $json.body }}",
        "options": {
          "responseCode": 200
        }
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.4,
      "position": [
        80,
        -240
      ],
      "name": "Reply to Tana"
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Exa Search",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Exa Search": {
      "main": [
        [
          {
            "node": "Code in JavaScript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript": {
      "main": [
        [
          {
            "node": "Reply to Tana",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1"
  },
  "tags": []
}