{
  "name": "Sitemap → IndexNow (Bing, Yandex, Seznam…)",
  "nodes": [
    {
      "id": "75f9d2d8-dc56-494b-9592-447e41c595e9",
      "name": "Cada hora",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        0
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "20 * * * *"
            }
          ]
        }
      }
    },
    {
      "id": "3b0ecf74-bfc1-4f41-9a65-5773654cdd73",
      "name": "Avisar a IndexNow",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        260,
        0
      ],
      "parameters": {
        "jsCode": "// Avisa a Bing (y al resto de buscadores con IndexNow) de las páginas nuevas del sitemap,\n// y una vez al día de las páginas que cambian cada día. La clave es pública: TU-WEB.com/<KEY>.txt\nconst KEY = 'PON-AQUI-TU-CLAVE'; // 32 caracteres hex; sube TU-CLAVE.txt con la clave a la raíz de tu web\nconst SITE = 'https://TU-WEB.com';\nconst sd = $getWorkflowStaticData('global');\nsd.sent = sd.sent || {};\nconst xml = await this.helpers.httpRequest({ url: SITE + '/sitemap.xml', json: false });\nconst locs = [...String(xml).matchAll(/<loc>([^<]+)<\\/loc>/g)].map((m) => m[1].trim()).filter((u) => u.startsWith(SITE));\nif (locs.length < 10) throw new Error('El sitemap parece vacío (' + locs.length + ' direcciones)');\nconst today = $now.setZone('Europe/Madrid').toISODate();\nconst HUBS = ['/', '/blog'].map((p) => SITE + (p === '/' ? '/' : p));\nlet list = locs.filter((u) => !sd.sent[u]);\nif (sd.hubsDay !== today) list = [...new Set([...list, ...HUBS.filter((h) => locs.includes(h))])];\nif (!list.length) return [];\nconst r = await this.helpers.httpRequest({\n  method: 'POST',\n  url: 'https://api.indexnow.org/indexnow',\n  headers: { 'Content-Type': 'application/json; charset=utf-8' },\n  body: { host: new URL(SITE).host, key: KEY, keyLocation: `${SITE}/${KEY}.txt`, urlList: list.slice(0, 10000) },\n  json: true,\n  returnFullResponse: true,\n  ignoreHttpStatusErrors: true,\n});\nif (r.statusCode !== 200 && r.statusCode !== 202) throw new Error('IndexNow respondió ' + r.statusCode + ': ' + JSON.stringify(r.body || '').slice(0, 300));\nfor (const u of list) sd.sent[u] = today;\nsd.hubsDay = today;\nreturn [{ json: { enviadas: list.length, estado: r.statusCode } }];\n"
      }
    }
  ],
  "connections": {
    "Cada hora": {
      "main": [
        [
          {
            "node": "Avisar a IndexNow",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "timezone": "Europe/Madrid",
    "saveDataSuccessExecution": "none"
  },
  "active": false
}