{
  "id": "CCBVu5HDUlX8U3ID",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Get email alerts for dropped top 10 keyword rankings with DataForSEO",
  "tags": [],
  "nodes": [
    {
      "id": "e8a35e6a-1a83-46f5-b26a-d7395533064a",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        0,
        432
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "weeks",
              "triggerAtDay": [
                1
              ],
              "triggerAtHour": 9
            }
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "e37ec900-8560-4c3a-b18a-9c0b80ea705f",
      "name": "Get ranked keywords",
      "type": "n8n-nodes-dataforseo.dataForSeoLabsApi",
      "position": [
        1344,
        352
      ],
      "parameters": {
        "limit": 1000,
        "offset": "={{ $runIndex * 1000 }}",
        "operation": "get-ranked-keywords",
        "target_any": "dataforseo.com",
        "language_name": "english",
        "location_name": "united states"
      },
      "credentials": {
        "dataForSeoApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "f58585b8-d7c0-48ec-a0b4-615ed8e57f35",
      "name": "Aggregate",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        448,
        432
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData"
      },
      "typeVersion": 1
    },
    {
      "id": "a6dc99eb-ae28-4ee8-bbbe-1a1fbf3ec44d",
      "name": "Append row in sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2688,
        432
      ],
      "parameters": {
        "columns": {
          "value": {
            "Rank": "={{ $('Split out (items)').item.json.ranked_serp_element.serp_item.rank_group }}",
            "Keyword": "={{ $('Split out (items)').item.json.keyword_data.keyword }}"
          },
          "schema": [
            {
              "id": "Keyword",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Keyword",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Rank",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Rank",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 641820442,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10G-tFbJC__V6_dBjGTGYR50DQPwUtX29_M3zohTz4WE/edit#gid=641820442",
          "cachedResultName": "Keywords"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "10G-tFbJC__V6_dBjGTGYR50DQPwUtX29_M3zohTz4WE",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10G-tFbJC__V6_dBjGTGYR50DQPwUtX29_M3zohTz4WE/edit?usp=drivesdk",
          "cachedResultName": "Dropped Keywords from Top10/3/1"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "5ef1ed8f-9551-4b02-86c5-0a56cc54d585",
      "name": "Aggregate1",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        3136,
        432
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData"
      },
      "typeVersion": 1
    },
    {
      "id": "12921ffe-4297-4eec-865f-6df4c6bca687",
      "name": "Filter items with rank > 10",
      "type": "n8n-nodes-base.filter",
      "position": [
        2464,
        432
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "ec75f033-d2c6-4837-b145-989b454fb662",
              "operator": {
                "type": "number",
                "operation": "lt"
              },
              "leftValue": "={{ $json.ranked_serp_element.serp_item.rank_group }}",
              "rightValue": 11
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "277510ef-7e7f-4911-8b58-a1856e1320af",
      "name": "Switch",
      "type": "n8n-nodes-base.switch",
      "position": [
        912,
        1216
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "previous Top 1",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "26d3d7c7-b9e2-44f4-95c9-313f3746f725",
                    "operator": {
                      "type": "number",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.Rank }}",
                    "rightValue": 1
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "privious Top 3",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "54bcbb2b-c3e4-4d3c-b3e7-fce0674b5cca",
                    "operator": {
                      "type": "number",
                      "operation": "lt"
                    },
                    "leftValue": "={{ $json.Rank }}",
                    "rightValue": 4
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "previous Top 10",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "f6a397b1-0707-41b8-b2f4-0b30795bd992",
                    "operator": {
                      "type": "number",
                      "operation": "lt"
                    },
                    "leftValue": "={{ $json.Rank }}",
                    "rightValue": 11
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.4
    },
    {
      "id": "e065ea70-b4aa-4a82-bc2a-a82c5231ffb0",
      "name": "Get live google organic SERP regular",
      "type": "n8n-nodes-dataforseo.dataForSeoSerpApi",
      "position": [
        1568,
        944
      ],
      "parameters": {
        "depth": 1,
        "keyword": "={{ $json.Keyword }}",
        "language_name": "={{ $('Get ranked keywords').item.json.tasks[0].data.language_name }}",
        "location_name": "={{ $('Get ranked keywords').item.json.tasks[0].data.location_name }}",
        "max_crawl_pages": 10
      },
      "credentials": {
        "dataForSeoApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "dee22441-cf1c-4391-8276-6fffb39fdbdf",
      "name": "Get live google organic SERP regular1",
      "type": "n8n-nodes-dataforseo.dataForSeoSerpApi",
      "position": [
        1536,
        1248
      ],
      "parameters": {
        "depth": 3,
        "keyword": "={{ $json.Keyword }}",
        "language_name": "={{ $('Get ranked keywords').item.json.tasks[0].data.language_name }}",
        "location_name": "={{ $('Get ranked keywords').item.json.tasks[0].data.location_name }}",
        "max_crawl_pages": 10
      },
      "credentials": {
        "dataForSeoApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ff7c2ab4-a8d7-4056-b5ba-7997fbe77ce7",
      "name": "Get live google organic SERP regular2",
      "type": "n8n-nodes-dataforseo.dataForSeoSerpApi",
      "position": [
        1520,
        1584
      ],
      "parameters": {
        "depth": 10,
        "keyword": "={{ $json.Keyword }}",
        "language_name": "={{ $('Get ranked keywords').item.json.tasks[0].data.language_name }}",
        "location_name": "={{ $('Get ranked keywords').item.json.tasks[0].data.location_name }}",
        "max_crawl_pages": 10
      },
      "credentials": {
        "dataForSeoApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "399eb5c0-6e0c-492e-898a-08d21730421e",
      "name": "Aggregate2",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        2112,
        944
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData"
      },
      "typeVersion": 1
    },
    {
      "id": "bf79e569-784c-455d-b2b9-d65a9e2d3017",
      "name": "Aggregate3",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        2112,
        1248
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData"
      },
      "typeVersion": 1
    },
    {
      "id": "d66f5e21-8e37-49c7-85f1-b3a68b33c041",
      "name": "Aggregate4",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        2112,
        1584
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData"
      },
      "typeVersion": 1
    },
    {
      "id": "8d3d528e-e9fa-4e7e-89b6-d5fcf77b02c3",
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "position": [
        2672,
        1200
      ],
      "parameters": {
        "numberInputs": 3
      },
      "typeVersion": 3.2
    },
    {
      "id": "e744c8b2-8e75-4385-9e55-80ec507f2ef5",
      "name": "Aggregate5",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        2880,
        1216
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData"
      },
      "typeVersion": 1
    },
    {
      "id": "24713785-8aa8-4136-beaf-65c80fc4b1f0",
      "name": "Get previous keywords",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        224,
        432
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 641820442,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10G-tFbJC__V6_dBjGTGYR50DQPwUtX29_M3zohTz4WE/edit#gid=641820442",
          "cachedResultName": "Keywords"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "10G-tFbJC__V6_dBjGTGYR50DQPwUtX29_M3zohTz4WE",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10G-tFbJC__V6_dBjGTGYR50DQPwUtX29_M3zohTz4WE/edit?usp=drivesdk",
          "cachedResultName": "Dropped Keywords from Top10/3/1"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7,
      "alwaysOutputData": true
    },
    {
      "id": "7fc57acc-f28d-441f-94b6-41fd81336875",
      "name": "Clear sheet (previous keywords)",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        672,
        432
      ],
      "parameters": {
        "operation": "clear",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 641820442,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10G-tFbJC__V6_dBjGTGYR50DQPwUtX29_M3zohTz4WE/edit#gid=641820442",
          "cachedResultName": "Keywords"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "10G-tFbJC__V6_dBjGTGYR50DQPwUtX29_M3zohTz4WE",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10G-tFbJC__V6_dBjGTGYR50DQPwUtX29_M3zohTz4WE/edit?usp=drivesdk",
          "cachedResultName": "Dropped Keywords from Top10/3/1"
        },
        "keepFirstRow": true
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "27316730-ae4f-4f92-988b-ee3659b47e5c",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        784
      ],
      "parameters": {
        "width": 432,
        "height": 672,
        "content": "This workflow uses the DataForSEO APIs to spot keywords for which your domain dropped out of Google\u2019s top 10 results. It compares the latest rankings with the previous week\u2019s snapshot, enriches each lost keyword with fresh SERP data and competitor insights, and sends you a structured Gmail alert.\n\n## How it works\n1. Runs on a predefined schedule (default: weekly).\n2. Reads your keywords and domains from Google Sheets.\n3. Fetches the latest Google rankings and competitor insights via DataForSEO APIs.\n4. Compares data to detect keywords that previously ranked in the top 10 but have since dropped out.\n5. Logs keywords that lost their top 10 ranks, along with current positions and competitor replacements, into Google Sheets.\n6. Sends a structured email summary.\n\n\n## Setup steps\n1. Indicate your spreadsheet where keywords should be saved.\n2. Create or select your DataForSEO connection (use [your API login and password](https://app.dataforseo.com/api-access)), specify a target domain, and other settings to get ranked keywords.\n3. Connect your Gmail to receive a summary email.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "ae363d85-059f-44a3-866d-28a9cf30a3bc",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        176,
        272
      ],
      "parameters": {
        "color": 6,
        "width": 640,
        "height": 368,
        "content": "## Get previous keywords and clear the sheet\nCreate a Google Sheets connection and select the spreadsheet where keywords should be saved. The sheet must have the same columns as in [this Example](https://docs.google.com/spreadsheets/d/10G-tFbJC__V6_dBjGTGYR50DQPwUtX29_M3zohTz4WE/edit?usp=sharing)."
      },
      "typeVersion": 1
    },
    {
      "id": "613d5984-bd6c-4d17-997c-f7fc3ea9ddd4",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        864,
        272
      ],
      "parameters": {
        "color": 6,
        "width": 1296,
        "height": 368,
        "content": "## Get ranked keywords keywords with DataForSEO\n Create a DataForSEO connection and specify the Target Domain, Location, and Language. Set up additional parameters if needed."
      },
      "typeVersion": 1
    },
    {
      "id": "541e2a86-f2b2-4a2c-b711-77660b1667ec",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2224,
        272
      ],
      "parameters": {
        "color": 6,
        "width": 1472,
        "height": 368,
        "content": "## Add new Top 10 keywords to Google Sheets and calculate Top 1, Top 3, and Top 10 results\nSelect the same spreadsheet with your keywords as in the first Google Sheets node."
      },
      "typeVersion": 1
    },
    {
      "id": "b905f0f6-c5d4-4b25-a04c-6474844f6c48",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        672,
        784
      ],
      "parameters": {
        "color": 6,
        "width": 2576,
        "height": 1072,
        "content": "## Find keywords that dropped from Top 1, Top 3, Top 10. Prepare data for email and send it\nCreate a DataForSEO connection and set up additional parameters if needed.\nCreate a Gmail connection and set a receiver. Add additional information to the message if needed."
      },
      "typeVersion": 1
    },
    {
      "id": "fc2520f0-6cd6-4f48-b43a-59714c0f65da",
      "name": "Initialize \"items\" field",
      "type": "n8n-nodes-base.set",
      "position": [
        896,
        432
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "71e223fc-37e5-4228-8e71-c2486bcebefe",
              "name": "items",
              "type": "array",
              "value": "={{ [] }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "24511182-e847-4420-b2e9-9cd38d63e04d",
      "name": "Set \"items\" field",
      "type": "n8n-nodes-base.set",
      "position": [
        1120,
        432
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "c34eb9db-52fb-43fb-afb3-a4234ed9d8f7",
              "name": "items",
              "type": "array",
              "value": "={{ $json.items }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "40d4ef86-7c33-4305-a60e-fb77bec0cecc",
      "name": "Has more pages?",
      "type": "n8n-nodes-base.if",
      "position": [
        1792,
        416
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "52b98b6e-30dd-4dfc-be39-95cd054c4445",
              "operator": {
                "type": "number",
                "operation": "lt"
              },
              "leftValue": "={{  $runIndex }}",
              "rightValue": "={{ $('Get ranked keywords').item.json.tasks[0].result[0].total_count / 1000 -1 }}"
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "d24fc0bd-8a82-45bc-ba62-375140d9796b",
      "name": "Merge \"items\" with DFS response",
      "type": "n8n-nodes-base.set",
      "position": [
        1568,
        352
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "7d7d12c4-7be0-4d4e-909f-52d62dcd21e1",
              "name": "items",
              "type": "array",
              "value": "={{ [ ...$('Set \"items\" field').item.json.items, ...$json.tasks[0].result[0].items] }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "f422f95f-a37c-47f2-a2d2-38fcbbc30af2",
      "name": "Merge \"items\" with last response",
      "type": "n8n-nodes-base.set",
      "position": [
        2016,
        432
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "56b0fdce-8c8c-454f-99c2-8d27be02111f",
              "name": "items",
              "type": "array",
              "value": "={{ [...$('Set \"items\" field').item.json.items, ...$('Get ranked keywords').item.json.tasks[0].result[0].items] }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "a8686a63-5f02-4041-a8c4-014cee7a3b88",
      "name": "Split out (items)",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        2240,
        432
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "items"
      },
      "typeVersion": 1
    },
    {
      "id": "0d2eafc4-da2c-46fa-b367-6f12f5fb53df",
      "name": "Filter (data for comparing is not empty)",
      "type": "n8n-nodes-base.filter",
      "position": [
        3328,
        432
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "1619ef3a-c6d6-4d20-b839-c70b6647a89d",
              "operator": {
                "type": "array",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $('Aggregate').item.json.data }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "a8e6696f-fc00-4501-b301-408aa84ec06a",
      "name": "Split out (previous keywords)",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        688,
        1232
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "previousItems"
      },
      "typeVersion": 1
    },
    {
      "id": "65f1285a-7a96-4e56-9c21-1d3de176cca6",
      "name": "Split out (SERP results)",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        1760,
        944
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "tasks[0].result[0].items"
      },
      "typeVersion": 1
    },
    {
      "id": "b791d00f-4369-42fa-8279-d02876fc8102",
      "name": "Split out (SERP results)1",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        1744,
        1248
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "tasks[0].result[0].items"
      },
      "typeVersion": 1
    },
    {
      "id": "b6593867-8b2c-47a0-a8b9-acf1041ea7ba",
      "name": "Split out (SERP results)2",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        1728,
        1584
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "tasks[0].result[0].items"
      },
      "typeVersion": 1
    },
    {
      "id": "a2964b99-b37b-42e5-9aaf-e1beab103bbf",
      "name": "Send a message",
      "type": "n8n-nodes-base.gmail",
      "position": [
        3104,
        1216
      ],
      "parameters": {
        "sendTo": "user@example.com",
        "message": "=<html> <body> <h2>Keywords Dropped from Top1</h2>\n{{ $json.data.map(item => item.top1).join('') }}\n<h2>Keywords Dropped from Top3</h2> {{ $json.data.map(item => item.top3).join('') }}  <h2>Keywords Dropped from Top10</h2> {{ $json.data.map(item => item.top10).join('') }}  </body> </html>",
        "options": {},
        "subject": "Dropped keywords"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "bf6f80af-a0e9-409c-be75-d7a0eda1ca0b",
      "name": "Set Top 1, Top 3, Top 10",
      "type": "n8n-nodes-base.set",
      "position": [
        2912,
        432
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "05bb706e-34fc-4cc3-b4c8-16d7eae5e0e1",
              "name": "top1",
              "type": "string",
              "value": "={{ $('Split out (items)').item.json.ranked_serp_element.serp_item.rank_group == 1 ? $('Split out (items)').item.json.keyword_data.keyword : null}}"
            },
            {
              "id": "42836c25-e5bb-416b-8caa-521a726d8390",
              "name": "top3",
              "type": "string",
              "value": "={{ $('Split out (items)').item.json.ranked_serp_element.serp_item.rank_group < 4 ? $('Split out (items)').item.json.keyword_data.keyword : null}}"
            },
            {
              "id": "54f863c3-9ca5-4127-af93-46f4eede0777",
              "name": "=top10",
              "type": "string",
              "value": "={{ $('Split out (items)').item.json.ranked_serp_element.serp_item.rank_group < 11 ? $('Split out (items)').item.json.keyword_data.keyword : null}}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "8bc0409d-0c83-4979-aa09-c09a9133470e",
      "name": "Filter Top 1, Top 2, Top 3",
      "type": "n8n-nodes-base.set",
      "position": [
        3520,
        432
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "a1240e66-6cb4-4a6d-8894-1ef970284c56",
              "name": "top1",
              "type": "array",
              "value": "={{ $json.data.map(item => item.top1).filter(item => item !== null) }}"
            },
            {
              "id": "68d4c4a8-2e3a-4bc5-8cb4-2ecd0e45b85f",
              "name": "top3",
              "type": "array",
              "value": "={{ $json.data.map(item => item.top3).filter(item => item !== null) }}"
            },
            {
              "id": "d131aaec-2fab-4143-8580-ff61501e4f6a",
              "name": "top10",
              "type": "array",
              "value": "={{ $json.data.map(item => item.top10).filter(item => item !== null) }}"
            },
            {
              "id": "3ccb284e-cab2-4529-863d-00bb331b21be",
              "name": "previousItems",
              "type": "array",
              "value": "={{ $('Aggregate').item.json.data }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "39a4437a-6fd6-4ef3-b949-b48d78bda22e",
      "name": "Filter (dropped from Top 3)",
      "type": "n8n-nodes-base.filter",
      "position": [
        1152,
        1232
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "53da0309-1d8b-4438-91d0-c51decb96aee",
              "operator": {
                "type": "array",
                "operation": "notContains",
                "rightType": "any"
              },
              "leftValue": "={{ $('Filter Top 1, Top 2, Top 3').item.json.top3 }}",
              "rightValue": "={{ $json.Keyword }}"
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "10e2e4a5-49e0-4c01-b98c-cf7496115e63",
      "name": "Filter (dropped from Top 10)",
      "type": "n8n-nodes-base.filter",
      "position": [
        1136,
        1568
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "0d81b485-26b2-4660-8444-115d4c1b5622",
              "operator": {
                "type": "array",
                "operation": "notContains",
                "rightType": "any"
              },
              "leftValue": "={{ $('Filter Top 1, Top 2, Top 3').item.json.top10 }}",
              "rightValue": "={{ $json.Keyword }}"
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "7c3b8c6b-5b07-4ad9-abd5-b766019a20e1",
      "name": "Loop Over Top 1 Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        1376,
        928
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "fbcafc38-9b18-4b4e-b475-dce32a85d7d9",
      "name": "Loop Over Top 2 Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        1376,
        1232
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "f0bdfa67-f9df-485e-95e2-6431e1b4d7ba",
      "name": "Loop Over Top 3 Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        1344,
        1568
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "2c4a910d-2d9b-4135-927e-a8acd0a2367b",
      "name": "Filter (dropped from Top 1)",
      "type": "n8n-nodes-base.filter",
      "position": [
        1152,
        1008
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "206988ee-574a-48d5-94c4-897250074027",
              "operator": {
                "type": "array",
                "operation": "notContains",
                "rightType": "any"
              },
              "leftValue": "={{ $('Filter Top 1, Top 2, Top 3').item.json.top1 }}",
              "rightValue": "={{ $json.Keyword }}"
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "cddb9271-365d-4711-8b36-2e21b1f2d5fd",
      "name": "Prepare email content",
      "type": "n8n-nodes-base.set",
      "position": [
        1936,
        944
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "44371769-b2cf-4c63-9918-bd1f4e15b5ee",
              "name": "competitor",
              "type": "string",
              "value": "=<tr> <td>{{ $json.domain }}</td> <td>{{ $json.url }}</td> <td>{{ $json.rank_group }}</td> <td>{{ $json.title }}</td> <td>{{ $json.description }}</td> </tr>"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "d7ee6b85-2d02-4145-bc1b-e96f36c8ddcf",
      "name": "Prepare email content1",
      "type": "n8n-nodes-base.set",
      "position": [
        2288,
        944
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "f5c36fa6-617c-49ef-8156-db4285f8d583",
              "name": "top1",
              "type": "string",
              "value": "=<p><b>Keyword:</b> {{ $('Loop Over Top 1 Items').item.json.Keyword }}; <b>Previous Rank:</b> {{ $('Loop Over Top 1 Items').item.json.Rank }}; <b>Current Rank:</b> {{ $('Merge \"items\" with last response').item.json.items.filter(item => item.keyword_data.keyword == $('Loop Over Top 1 Items').item.json.Keyword).map(item => item.ranked_serp_element.serp_item.rank_group).first() || null }}</p> <h3>Current TOP1 positions</h3> <table> <tr> <th>Domain</th> <th>URL</th> <th>Rank</th> <th>Title</th> <th>Description</th> </tr> {{ $json.data.map(item => item.competitor).join('') }} </table>"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "1f74d853-8226-4978-869a-940e7477f8aa",
      "name": "Prepare email content2",
      "type": "n8n-nodes-base.set",
      "position": [
        1936,
        1248
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "44371769-b2cf-4c63-9918-bd1f4e15b5ee",
              "name": "competitor",
              "type": "string",
              "value": "=<tr> <td>{{ $json.domain }}</td> <td>{{ $json.url }}</td> <td>{{ $json.rank_group }}</td> <td>{{ $json.title }}</td> <td>{{ $json.description }}</td> </tr>"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "29b9a73a-27ec-4b9b-a189-23853af1774a",
      "name": "Prepare email content3",
      "type": "n8n-nodes-base.set",
      "position": [
        2304,
        1248
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "f5c36fa6-617c-49ef-8156-db4285f8d583",
              "name": "top3",
              "type": "string",
              "value": "=<p><b>Keyword: </b>{{ $('Loop Over Top 2 Items').item.json.Keyword }}; <b>Previous Rank:</b> {{ $('Loop Over Top 2 Items').item.json.Rank }}; <b>Current Rank:</b> {{ $('Merge \"items\" with last response').item.json.items.filter(item => item.keyword_data.keyword == $('Loop Over Top 2 Items').item.json.Keyword).map(item => item.ranked_serp_element.serp_item.rank_group).first() || null }}</p> <h3>Current TOP3 positions</h3> <table> <tr> <th>Domain</th> <th>URL</th> <th>Rank</th> <th>Title</th> <th>Description</th> </tr> {{ $json.data.map(item => item.competitor).join('') }} </table>"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "87a9cf06-0731-4ec2-81d1-6113267654c5",
      "name": "Prepare email content4",
      "type": "n8n-nodes-base.set",
      "position": [
        1920,
        1584
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "44371769-b2cf-4c63-9918-bd1f4e15b5ee",
              "name": "competitor",
              "type": "string",
              "value": "=<tr> <td>{{ $json.domain }}</td> <td>{{ $json.url }}</td> <td>{{ $json.rank_group }}</td> <td>{{ $json.title }}</td> <td>{{ $json.description }}</td> </tr>"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "c3506482-2b1e-4fe4-b0c1-4130285c81f3",
      "name": "Prepare email content5",
      "type": "n8n-nodes-base.set",
      "position": [
        2272,
        1584
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "f5c36fa6-617c-49ef-8156-db4285f8d583",
              "name": "top10",
              "type": "string",
              "value": "=<p><b>Keyword: </b>{{ $('Loop Over Top 3 Items').item.json.Keyword }}; <b>Previous Rank:</b> {{ $('Loop Over Top 3 Items').item.json.Rank }}; <b>Current Rank:</b> {{ $('Merge \"items\" with last response').item.json.items.filter(item => item.keyword_data.keyword == $('Loop Over Top 3 Items').item.json.Keyword).map(item => item.ranked_serp_element.serp_item.rank_group).first() || null }}</p> <h3>Current TOP10 positions</h3> <table> <tr> <th>Domain</th> <th>URL</th> <th>Rank</th> <th>Title</th> <th>Description</th> </tr> {{ $json.data.map(item => item.competitor).join('') }} </table>"
            }
          ]
        }
      },
      "typeVersion": 3.4
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "47863b41-3cfe-471f-bc3d-1463e8819093",
  "connections": {
    "Merge": {
      "main": [
        [
          {
            "node": "Aggregate5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Filter (dropped from Top 1)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Filter (dropped from Top 3)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Filter (dropped from Top 10)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate": {
      "main": [
        [
          {
            "node": "Clear sheet (previous keywords)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate1": {
      "main": [
        [
          {
            "node": "Filter (data for comparing is not empty)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate2": {
      "main": [
        [
          {
            "node": "Prepare email content1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate3": {
      "main": [
        [
          {
            "node": "Prepare email content3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate4": {
      "main": [
        [
          {
            "node": "Prepare email content5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate5": {
      "main": [
        [
          {
            "node": "Send a message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Has more pages?": {
      "main": [
        [
          {
            "node": "Set \"items\" field",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Merge \"items\" with last response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Get previous keywords",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set \"items\" field": {
      "main": [
        [
          {
            "node": "Get ranked keywords",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split out (items)": {
      "main": [
        [
          {
            "node": "Filter items with rank > 10",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append row in sheet": {
      "main": [
        [
          {
            "node": "Set Top 1, Top 3, Top 10",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get ranked keywords": {
      "main": [
        [
          {
            "node": "Merge \"items\" with DFS response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get previous keywords": {
      "main": [
        [
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Top 1 Items": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get live google organic SERP regular",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Top 2 Items": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ],
        [
          {
            "node": "Get live google organic SERP regular1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Top 3 Items": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 2
          }
        ],
        [
          {
            "node": "Get live google organic SERP regular2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare email content": {
      "main": [
        [
          {
            "node": "Aggregate2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare email content1": {
      "main": [
        [
          {
            "node": "Loop Over Top 1 Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare email content2": {
      "main": [
        [
          {
            "node": "Aggregate3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare email content3": {
      "main": [
        [
          {
            "node": "Loop Over Top 2 Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare email content4": {
      "main": [
        [
          {
            "node": "Aggregate4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare email content5": {
      "main": [
        [
          {
            "node": "Loop Over Top 3 Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Initialize \"items\" field": {
      "main": [
        [
          {
            "node": "Set \"items\" field",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Top 1, Top 3, Top 10": {
      "main": [
        [
          {
            "node": "Aggregate1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split out (SERP results)": {
      "main": [
        [
          {
            "node": "Prepare email content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split out (SERP results)1": {
      "main": [
        [
          {
            "node": "Prepare email content2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split out (SERP results)2": {
      "main": [
        [
          {
            "node": "Prepare email content4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Top 1, Top 2, Top 3": {
      "main": [
        [
          {
            "node": "Split out (previous keywords)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter (dropped from Top 1)": {
      "main": [
        [
          {
            "node": "Loop Over Top 1 Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter (dropped from Top 3)": {
      "main": [
        [
          {
            "node": "Loop Over Top 2 Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter items with rank > 10": {
      "main": [
        [
          {
            "node": "Append row in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter (dropped from Top 10)": {
      "main": [
        [
          {
            "node": "Loop Over Top 3 Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split out (previous keywords)": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Clear sheet (previous keywords)": {
      "main": [
        [
          {
            "node": "Initialize \"items\" field",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge \"items\" with DFS response": {
      "main": [
        [
          {
            "node": "Has more pages?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge \"items\" with last response": {
      "main": [
        [
          {
            "node": "Split out (items)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get live google organic SERP regular": {
      "main": [
        [
          {
            "node": "Split out (SERP results)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get live google organic SERP regular1": {
      "main": [
        [
          {
            "node": "Split out (SERP results)1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get live google organic SERP regular2": {
      "main": [
        [
          {
            "node": "Split out (SERP results)2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter (data for comparing is not empty)": {
      "main": [
        [
          {
            "node": "Filter Top 1, Top 2, Top 3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}