{
  "name": "Submit new pages to IndexNow, then check Google indexing a few days later (GSC Magic)",
  "nodes": [
    {
      "id": "a0322390-c46e-4c43-aaf9-21c59a6d5640",
      "name": "New page published",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        0
      ],
      "webhookId": "8745e91a-55c5-467c-a8b4-03e64c315b80",
      "parameters": {
        "httpMethod": "POST",
        "path": "gsc-magic-new-page",
        "responseMode": "responseNode",
        "options": {}
      }
    },
    {
      "id": "5cf57de3-70f3-472b-a8e5-df4112eb4d4f",
      "name": "Settings",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        308,
        0
      ],
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "b3ec14b3-771a-424e-a6ca-aa61b73a6cd2",
              "name": "site",
              "value": "example.com",
              "type": "string"
            },
            {
              "id": "cd0f7faa-770c-4e69-a253-2b6703c394f4",
              "name": "waitDays",
              "value": 3,
              "type": "number"
            },
            {
              "id": "7a5701a4-9027-4072-a6a0-27c2de91f6bf",
              "name": "slackChannel",
              "value": "#seo-alerts",
              "type": "string"
            }
          ]
        },
        "options": {}
      }
    },
    {
      "id": "2334a6f2-0268-41ca-a138-e4a4935e8bd1",
      "name": "Check the submitted URLs",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        616,
        0
      ],
      "parameters": {
        "jsCode": "const cfg = $('Settings').first().json;\nconst req = $('New page published').first().json;\nconst body = (req.body && typeof req.body === 'object') ? req.body : {};\nconst raw = [].concat(body.urls || [], body.url || [], body.link || [], (req.query && req.query.url) || []);\n\nconst siteHost = String(cfg.site).toLowerCase().replace(/^sc-domain:/, '').replace(/^https?:\\/\\//, '').replace(/\\/.*$/, '').replace(/^www\\./, '');\nconst fail = (reason) => [{ json: { valid: false, reason } }];\nif (!raw.length) return fail('Send JSON like {\"url\": \"https://' + siteHost + '/new-page/\"}');\nif (raw.length > 20) return fail('Send at most 20 URLs per call');\n\n// The Code node sandbox has no URL class, so URLs are split with a regular expression.\nconst urls = [];\nfor (const value of raw) {\n  const m = String(value).trim().match(/^(https?):\\/\\/([^/?#:@\\s]+)(:\\d+)?([^#\\s]*)/i);\n  if (!m) return fail('Not an http(s) URL: ' + value);\n  const host = m[2].toLowerCase().replace(/^www\\./, '');\n  if (host !== siteHost && !host.endsWith('.' + siteHost)) return fail(value + ' is not on ' + siteHost);\n  urls.push(m[1].toLowerCase() + '://' + m[2].toLowerCase() + (m[3] || '') + (m[4] || '/'));\n}\nconst hosts = new Set(urls.map((x) => x.split('/')[2]));\nif (hosts.size > 1) return fail('All URLs in one call must share one host (IndexNow rule)');\n\n// Skip URLs submitted in the last 24 hours, so repeated saves do not resubmit.\nconst store = $getWorkflowStaticData('global');\nstore.submitted = store.submitted || {};\nconst now = Date.now();\nfor (const [u, t] of Object.entries(store.submitted)) if (now - t > 24 * 60 * 60 * 1000) delete store.submitted[u];\nconst fresh = [...new Set(urls)].filter((u) => !store.submitted[u]);\nif (!fresh.length) return [{ json: { valid: true, duplicate: true, urls: [] } }];\nfor (const u of fresh) store.submitted[u] = now;\nreturn [{ json: { valid: true, duplicate: false, urls: fresh } }];\n"
      }
    },
    {
      "id": "e336623f-e7af-4cff-a591-b313fa7f0c6e",
      "name": "URLs accepted?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        924,
        0
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "f8e85141-7bd2-44a9-acc8-cc4711bc5941",
              "leftValue": "={{ $json.valid }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      }
    },
    {
      "id": "75daad1c-9a52-4b96-a0b6-3e0ac6ca180c",
      "name": "Reply 400",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        1232,
        160
      ],
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify({ error: $json.reason }) }}",
        "options": {
          "responseCode": 400
        }
      }
    },
    {
      "id": "8236bd83-b342-4bae-a834-82bb225fcf64",
      "name": "Reply 202",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        1232,
        -40
      ],
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify({ accepted: $json.urls, skipped_duplicate: $json.duplicate }) }}",
        "options": {
          "responseCode": 202
        }
      }
    },
    {
      "id": "ca7b16d8-a48a-408d-ac9a-68642f4b740f",
      "name": "Anything new?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        1540,
        -40
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "6fdf2a7a-2052-4d1f-aa96-11e1f22096ff",
              "leftValue": "={{ $json.urls.length > 0 }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      }
    },
    {
      "id": "25889c7e-1faf-436c-a81d-f3d8e396d7b5",
      "name": "GSC Magic: submit to IndexNow",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1848,
        -60
      ],
      "onError": "continueRegularOutput",
      "parameters": {
        "method": "POST",
        "url": "https://mcp.gscmagic.com/mcp",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/json, text/event-stream"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'tools/call', params: { name: 'indexnow_submit', arguments: { urls: $json.urls } } }) }}",
        "options": {
          "batching": {
            "batch": {
              "batchSize": 1,
              "batchInterval": 300
            }
          },
          "timeout": 180000
        }
      }
    },
    {
      "id": "cfe3fa82-ab4b-4291-afd4-9501011e1b8b",
      "name": "Remember the IndexNow result",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        2156,
        -60
      ],
      "parameters": {
        "jsCode": "// Turns a GSC Magic response (MCP JSON-RPC) into { ok, data, error, image }.\nfunction unwrap(res) {\n  const result = res && res.result;\n  if (result && Array.isArray(result.content)) {\n    const text = result.content.filter((b) => b.type === 'text').map((b) => b.text).join('\\n');\n    if (result.isError) return { ok: false, error: text || 'GSC Magic reported an error' };\n    let data;\n    try { data = JSON.parse(text); } catch (e) { data = { text }; }\n    const image = result.content.find((b) => b.type === 'image' && b.data);\n    return { ok: true, data, image };\n  }\n  const err = res && res.error;\n  const message = typeof err === 'string' ? err : (err && (err.message || err.description)) || 'No response from GSC Magic';\n  if (/401|unauthori[sz]ed|Authorization failed/i.test(message)) {\n    return { ok: false, error: 'GSC Magic rejected the access token (wrong, expired or revoked). Create a new one in the GSC Magic dashboard: Connect > Access tokens.' };\n  }\n  return { ok: false, error: String(message) };\n}\n\nconst res = unwrap($input.first().json);\nconst urls = $('Check the submitted URLs').first().json.urls;\nreturn [{ json: { urls, indexNow: res.ok ? 'submitted' : 'failed: ' + res.error } }];\n"
      }
    },
    {
      "id": "93e7540f-f4b2-436b-abea-1decfa9c73ab",
      "name": "Wait before checking Google",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        2464,
        -60
      ],
      "webhookId": "52b77059-39c5-4187-abde-3dd08ffa2d11",
      "parameters": {
        "amount": "={{ $('Settings').first().json.waitDays }}",
        "unit": "days"
      }
    },
    {
      "id": "2af48ea8-3c07-4cab-a1b2-a0bd4da876ed",
      "name": "GSC Magic: inspect in Google",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        2772,
        -60
      ],
      "onError": "continueRegularOutput",
      "parameters": {
        "method": "POST",
        "url": "https://mcp.gscmagic.com/mcp",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/json, text/event-stream"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'tools/call', params: { name: 'gsc_inspect_urls_batch', arguments: { site: $('Settings').first().json.site, urls: $json.urls } } }) }}",
        "options": {
          "batching": {
            "batch": {
              "batchSize": 1,
              "batchInterval": 300
            }
          },
          "timeout": 180000
        }
      }
    },
    {
      "id": "699e8270-d80d-4371-a3f8-22429e5c7085",
      "name": "Write the Slack message",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        3080,
        -60
      ],
      "parameters": {
        "jsCode": "// Turns a GSC Magic response (MCP JSON-RPC) into { ok, data, error, image }.\nfunction unwrap(res) {\n  const result = res && res.result;\n  if (result && Array.isArray(result.content)) {\n    const text = result.content.filter((b) => b.type === 'text').map((b) => b.text).join('\\n');\n    if (result.isError) return { ok: false, error: text || 'GSC Magic reported an error' };\n    let data;\n    try { data = JSON.parse(text); } catch (e) { data = { text }; }\n    const image = result.content.find((b) => b.type === 'image' && b.data);\n    return { ok: true, data, image };\n  }\n  const err = res && res.error;\n  const message = typeof err === 'string' ? err : (err && (err.message || err.description)) || 'No response from GSC Magic';\n  if (/401|unauthori[sz]ed|Authorization failed/i.test(message)) {\n    return { ok: false, error: 'GSC Magic rejected the access token (wrong, expired or revoked). Create a new one in the GSC Magic dashboard: Connect > Access tokens.' };\n  }\n  return { ok: false, error: String(message) };\n}\n\nconst cfg = $('Settings').first().json;\nconst before = $('Remember the IndexNow result').first().json;\nconst res = unwrap($input.first().json);\nconst lines = ['*New page check* (' + cfg.waitDays + ' days after publishing)', 'IndexNow: ' + before.indexNow];\n\nif (!res.ok) {\n  lines.push(':warning: Google check failed: ' + res.error);\n} else {\n  for (const r of res.data.results || []) {\n    const ok = r.verdict === 'PASS';\n    lines.push((ok ? ':large_green_circle: ' : ':red_circle: ') + '<' + r.url + '> ' + (r.coverageState || r.error || 'unknown')\n      + (r.lastCrawlTime ? ' (last crawl ' + r.lastCrawlTime.slice(0, 10) + ')' : ' (not crawled yet)'));\n  }\n  if ((res.data.results || []).some((r) => r.verdict !== 'PASS')) {\n    lines.push('_Not indexed yet: link to the page from a few strong pages and request indexing in Search Console._');\n  }\n}\nreturn [{ json: { text: lines.join('\\n') } }];\n"
      }
    },
    {
      "id": "5560c75d-0522-42d0-a959-14973536c665",
      "name": "Post to Slack",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.3,
      "position": [
        3388,
        -60
      ],
      "parameters": {
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "name",
          "value": "={{ $('Settings').first().json.slackChannel }}"
        },
        "text": "={{ $json.text }}",
        "otherOptions": {
          "includeLinkToWorkflow": false
        }
      }
    },
    {
      "id": "7edbd534-615a-42a5-a0ba-c9ef02e5a7e2",
      "name": "Step 1",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -40,
        -319
      ],
      "parameters": {
        "content": "## Step 1: Configure\n- **site**: your Search Console property or domain. Only URLs on this host are accepted.\n- **waitDays**: days to wait before the Google check. 3 to 7 is typical for a new page.\n- **slackChannel**: where the result goes.\n\nOptional: protect the webhook with **Header Auth** in the webhook node if your CMS can send a secret header.",
        "width": 488,
        "height": 669,
        "color": 7
      }
    },
    {
      "id": "f6e6c19c-84e3-42fe-ae17-5cb53c0da1d9",
      "name": "Step 2",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        576,
        -319
      ],
      "parameters": {
        "content": "## Step 2: Check the URLs and answer the CMS\nAccepts only URLs on your site, at most 20, one host per call. Repeats within 24 hours are skipped. The CMS gets 202 or 400 right away.",
        "width": 1104,
        "height": 669,
        "color": 7
      }
    },
    {
      "id": "d5f5a5b2-8fb4-4ad2-a80f-b17c1c0c5daf",
      "name": "Step 3",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1808,
        -319
      ],
      "parameters": {
        "content": "## Step 3: Submit to IndexNow\nNotifies Bing, Yandex, Seznam, Naver and other IndexNow engines and keeps the result for the report.",
        "width": 488,
        "height": 669,
        "color": 7
      }
    },
    {
      "id": "c6003a6e-3a98-4e96-a879-4db2b9759495",
      "name": "Step 4",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        2424,
        -319
      ],
      "parameters": {
        "content": "## Step 4: Check Google later\nWaits `waitDays`, inspects the URLs in Google and posts indexed or not, with the reason.",
        "width": 1104,
        "height": 669,
        "color": 7
      }
    },
    {
      "id": "559fbd57-61d2-4366-acde-dc48b11e68db",
      "name": "Overview",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -740,
        -319
      ],
      "parameters": {
        "content": "## Publish, ping IndexNow, check Google later\nYour CMS calls this webhook when a page is published or updated. The workflow submits the URL to IndexNow right away (Bing, Yandex, Seznam, Naver and others), waits a few days, then asks Google's URL Inspection API whether the page is indexed and posts the result to Slack.\n\n**Who it is for:** freelancers and small teams on WordPress, Webflow, Ghost or any CMS that can send a webhook.\n\n**How it works**\n1. Accepts `POST {\"url\": \"https://example.com/new-post/\"}` (or `{\"urls\": [...]}`, up to 20).\n2. Rejects URLs from another host and URLs already submitted in the last 24 hours (save-button spam).\n3. Answers the CMS immediately (202), then submits to IndexNow.\n4. After `waitDays` it inspects the URLs in Google and reports indexed or not, with the reason.\n\n**Requirements**\n- GSC Magic **Pro or Agency** with **write mode** on (Settings in the dashboard) and an **IndexNow key** added under Sources. IndexNow is a write action, so the token must NOT be read-only.\n\n**Connect GSC Magic** (about 2 minutes)\n1. In the [GSC Magic dashboard](https://app.gscmagic.com) open **Connect > Access tokens** and create a token. Copy the `gsm_...` value (shown once).\n2. Open the first node whose name starts with **GSC Magic:**, and under **Credential for Bearer Auth** create a new credential. Paste the token into **Bearer Token**. In every other **GSC Magic:** node, select that same credential.\n3. Never paste the token into a URL, a prompt or a Code node.\n\n**Then**\n4. Fill in **Settings**, add a Slack credential to **Post to Slack**, activate the workflow.\n5. Copy the production URL of **New page published** into your CMS webhook. Test with:\n`curl -X POST <webhook-url> -H 'Content-Type: application/json' -d '{\"url\":\"https://example.com/new-post/\"}'`\n\n**Calls per page:** 2 (submit + inspect).\n\n### Errors and limits\n- Bad input gets a 400 with the reason; nothing is submitted.\n- If IndexNow fails (no write mode, no key, read-only token) the Google check still runs and the Slack message shows why IndexNow failed.\n- Repeats of the same URL within 24 hours are skipped. Two requests a few seconds apart can both get through, because n8n saves the list only when a run reaches the Wait node.\n- The Wait node keeps the execution for `waitDays`. On n8n Cloud and self-hosted this survives restarts. Many waiting executions are fine, each costs no calls while waiting.\n- Google's URL Inspection API allows 2,000 inspections a day per property.",
        "width": 640,
        "height": 1056
      }
    }
  ],
  "connections": {
    "New page published": {
      "main": [
        [
          {
            "node": "Settings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Settings": {
      "main": [
        [
          {
            "node": "Check the submitted URLs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check the submitted URLs": {
      "main": [
        [
          {
            "node": "URLs accepted?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "URLs accepted?": {
      "main": [
        [
          {
            "node": "Reply 202",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Reply 400",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Reply 202": {
      "main": [
        [
          {
            "node": "Anything new?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Anything new?": {
      "main": [
        [
          {
            "node": "GSC Magic: submit to IndexNow",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GSC Magic: submit to IndexNow": {
      "main": [
        [
          {
            "node": "Remember the IndexNow result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Remember the IndexNow result": {
      "main": [
        [
          {
            "node": "Wait before checking Google",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait before checking Google": {
      "main": [
        [
          {
            "node": "GSC Magic: inspect in Google",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GSC Magic: inspect in Google": {
      "main": [
        [
          {
            "node": "Write the Slack message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Write the Slack message": {
      "main": [
        [
          {
            "node": "Post to Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "active": false
}
