{
  "name": "Google rank drops to email",
  "nodes": [
    {
      "parameters": {
        "content": "## Google rank drops \u2192 email\n1. Open **Run monitor** \u2192 Credential \u2192 *Header Auth*: Name `Authorization`, Value `Bearer YOUR_APIFY_TOKEN` (Apify Console \u2192 Settings \u2192 API & Integrations).\n2. Edit the JSON body: your domain, keywords, country and `trackingId`.\n3. Set SMTP credentials and addresses in **Email me**.\n\nRuns daily at 07:00 and emails keywords that fell 3+ positions or dropped out of the checked results. Change `-3` in **Big drops only** to tune it.",
        "height": 300,
        "width": 420
      },
      "id": "9a475800-e21c-432e-8f4b-cfb090df8d37",
      "name": "Setup",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -460,
        -120
      ]
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "days",
              "triggerAtHour": 7
            }
          ]
        }
      },
      "id": "899830e2-6670-419c-913a-b2832869c9e2",
      "name": "Every day 07:00",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.apify.com/v2/acts/kirozhang~serp-rank-tracker/run-sync-get-dataset-items",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "timeout",
              "value": "300"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "{\n  \"myDomain\": \"example.com\",\n  \"keywords\": [\n    \"crm for small business\",\n    \"best crm software\"\n  ],\n  \"competitorDomains\": [],\n  \"country\": \"us\",\n  \"language\": \"en\",\n  \"trackingId\": \"example-us\"\n}",
        "options": {
          "timeout": 310000
        }
      },
      "id": "53ba047d-1301-4b56-b5ff-d347cf268fd9",
      "name": "Run rank tracker",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        220,
        0
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose"
          },
          "conditions": [
            {
              "id": "eb6aa506-41ea-43c9-a409-1e9808d7b955",
              "leftValue": "={{ typeof $json.positionChange === 'number' ? $json.positionChange : 0 }}",
              "operator": {
                "type": "number",
                "operation": "lte"
              },
              "rightValue": -3
            },
            {
              "id": "2c053313-74fc-4041-b3b7-53241376ab70",
              "leftValue": "={{ $json.positionChange }}",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "rightValue": "dropped_out"
            }
          ],
          "combinator": "or"
        },
        "options": {}
      },
      "id": "2ead22a4-1fb7-4c0d-825c-26fd04e65c9a",
      "name": "Big drops only",
      "type": "n8n-nodes-base.filter",
      "typeVersion": 2,
      "position": [
        440,
        0
      ]
    },
    {
      "parameters": {
        "aggregate": "aggregateAllItemData",
        "options": {}
      },
      "id": "f40dc69b-3939-4597-b448-7d0944a319ae",
      "name": "Collect",
      "type": "n8n-nodes-base.aggregate",
      "typeVersion": 1,
      "position": [
        660,
        0
      ]
    },
    {
      "parameters": {
        "fromEmail": "alerts@example.com",
        "toEmail": "you@example.com",
        "subject": "={{ $json.data.length }} keyword(s) dropped on Google",
        "emailFormat": "text",
        "text": "={{ $json.data.map(r => `${r.keyword}: ${r.previousPosition ?? '-'} -> ${r.position ?? 'not in checked results'}  ${r.url || ''}`).join('\\n') }}",
        "options": {}
      },
      "id": "a6d063da-ba1b-4009-91fb-bc6ad3d76118",
      "name": "Email me",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 2.1,
      "position": [
        880,
        0
      ]
    }
  ],
  "connections": {
    "Every day 07:00": {
      "main": [
        [
          {
            "node": "Run rank tracker",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run rank tracker": {
      "main": [
        [
          {
            "node": "Big drops only",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Big drops only": {
      "main": [
        [
          {
            "node": "Collect",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Collect": {
      "main": [
        [
          {
            "node": "Email me",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {}
}