{
  "id": "vRvtSDa1kujhqycz",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Monitor lost backlinks with DataForSEO and get email reports",
  "tags": [],
  "nodes": [
    {
      "id": "01249746-9d41-410b-aa1f-f33038201f12",
      "name": "Initialize \"items\" field",
      "type": "n8n-nodes-base.set",
      "position": [
        128,
        624
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "0126c659-03a5-4fc8-bd76-62d2ecea1195",
              "name": "items",
              "type": "array",
              "value": "={{ [] }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "302d0a5e-7082-4af3-88f3-c49bfdc8ca8a",
      "name": "Merge \"items\" with DFS response",
      "type": "n8n-nodes-base.set",
      "position": [
        800,
        544
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "ddd82419-e43e-44d8-919c-2d6602704da5",
              "name": "items",
              "type": "array",
              "value": "={{ [ ...$('Set \"items\" field').item.json.items, ...$json.tasks[0].result[0].items] }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "d3248755-6b76-4a86-9505-5ef6d9e5febb",
      "name": "Has more pages?",
      "type": "n8n-nodes-base.if",
      "position": [
        1024,
        624
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "cd5943f7-df0b-4329-8436-9a1af3ec7caf",
              "operator": {
                "type": "number",
                "operation": "lt"
              },
              "leftValue": "={{ $runIndex }}",
              "rightValue": "={{ $('Get lost backlinks').item.json.tasks[0].result[0].total_count / 1000 - 1}}"
            },
            {
              "id": "9cd8ede8-c09a-4cbc-8050-5d23989ee07e",
              "operator": {
                "type": "number",
                "operation": "lt"
              },
              "leftValue": "={{ $runIndex }}",
              "rightValue": 5
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "6a03f798-1a64-46bf-b037-06173fbe4999",
      "name": "Filter (has new backlinks)",
      "type": "n8n-nodes-base.filter",
      "position": [
        -304,
        1088
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "648f4d1e-367c-41b2-b223-1363dadc2cc8",
              "operator": {
                "type": "number",
                "operation": "gt"
              },
              "leftValue": "={{ $('Get lost backlinks').item.json.tasks[0].result[0].total_count }}",
              "rightValue": 0
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "40f28904-5973-4b9a-bc25-c9778ecddb2e",
      "name": "Append columns",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        368,
        1088
      ],
      "parameters": {
        "columns": {
          "value": {},
          "schema": [],
          "mappingMode": "autoMapInputData",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Create spreadsheet').item.json.sheets[0].properties.sheetId }}"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Create spreadsheet').item.json.spreadsheetId }}"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "9c02c042-6c95-4942-84af-3ba19ca72439",
      "name": "Set final \"items\" field",
      "type": "n8n-nodes-base.set",
      "position": [
        592,
        1088
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "1e2c8353-5628-4948-abe6-35f8d0f660a5",
              "name": "items",
              "type": "array",
              "value": "={{ [...$('Set \"items\" field').item.json.items, ... $('Get lost backlinks').item.json.tasks[0].result[0].items]}}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "65056f6a-d5c3-4c76-bcb2-23d8ec744423",
      "name": "Split out items",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        816,
        1088
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "items"
      },
      "typeVersion": 1
    },
    {
      "id": "93ec0102-796e-4cae-901d-375aee4a813c",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        80,
        448
      ],
      "parameters": {
        "color": 6,
        "width": 1120,
        "height": 352,
        "content": "## Get lost backlinks with DataForSEO\nCreate a DataForSEO connection, specify a Target Domain, and set up additional parameters if needed."
      },
      "typeVersion": 1
    },
    {
      "id": "6ed937d0-8a63-4d3f-91b3-967c78e9d246",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -336,
        896
      ],
      "parameters": {
        "color": 6,
        "width": 2160,
        "height": 384,
        "content": "## Create a Google Sheet with lost backlinks and send it via email\nCreate a Google Sheets connection.\nCreate a Gmail connection and set a receiver."
      },
      "typeVersion": 1
    },
    {
      "id": "2b0d9190-f707-4d17-a1ed-6bcdf257fd95",
      "name": "Get lost backlinks",
      "type": "n8n-nodes-dataforseo.dataForSeoBacklinksApi",
      "position": [
        576,
        544
      ],
      "parameters": {
        "limit": 1000,
        "offset": "={{ $runIndex * 1000 }}",
        "target": "=dataforseo.com",
        "filters": "=[\"last_seen\", \">\", \"{{ $now.minus(1, \"days\").format(\"yyyy-MM-dd\") }}\"]",
        "operation": "get-backlinks",
        "include_indirect_links": false
      },
      "credentials": {
        "dataForSeoApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "56f9f2c5-91e6-4667-86f5-12026c52668e",
      "name": "Set \"items\" field",
      "type": "n8n-nodes-base.set",
      "position": [
        352,
        624
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "4b3c95a2-4e38-4e37-8e2f-a7e4544808d6",
              "name": "items",
              "type": "array",
              "value": "={{ $json.items }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "8f267be2-484a-4275-8079-f7036d8c877c",
      "name": "Create spreadsheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -80,
        1088
      ],
      "parameters": {
        "title": "=Lost Backlinks to  {{ $('Get lost backlinks').item.json.tasks[0].data.target }} - {{ $now.format(\"yyyy-MM-dd\") }}",
        "options": {},
        "resource": "spreadsheet",
        "sheetsUi": {
          "sheetValues": [
            {
              "title": "Lost Backlinks"
            }
          ]
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "775afb58-5971-4482-8fda-c9fbd732622d",
      "name": "Append row in sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1264,
        1088
      ],
      "parameters": {
        "columns": {
          "value": {},
          "schema": [
            {
              "id": "Date",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Target",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Target",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Backlink",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Backlink",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Spam Score",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Spam Score",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Backlink Rank",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Backlink Rank",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Domain from",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Domain from",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Domain from Rank",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Domain from Rank",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "URL from",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "URL from",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "URL from Rank",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "URL from Rank",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Backlink Is Broken",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Backlink Is Broken",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Backlinks Is Dofollow",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Backlinks Is Dofollow",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "autoMapInputData",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Create spreadsheet').item.json.sheets[0].properties.sheetId }}"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Create spreadsheet').item.json.spreadsheetId }}"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "2228f42d-03a3-468e-aa70-585b39516b7e",
      "name": "Send a message",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1696,
        1088
      ],
      "parameters": {
        "sendTo": "user@example.com",
        "message": "=<html> <body> <p>Here is your daily lost backlinks report for {{ $('Get lost backlinks').item.json.tasks[0].data.target }}.</p>  <p>During the past day, we identified {{ $('Get lost backlinks').item.json.tasks[0].result[0].total_count }} backlinks.</p>  You can review the full list here: <a href=\"{{ $('Create spreadsheet').item.json.spreadsheetUrl }}\">Lost Backlinks to  {{ $('Get lost backlinks').item.json.tasks[0].data.target }} - {{ $now.format(\"yyyy-MM-dd\") }}</a> </body> </html>",
        "options": {},
        "subject": "=Lost Backlinks to {{ $('Get lost backlinks').item.json.tasks[0].data.target }} - {{ $now.format(\"yyyy-MM-dd\") }}"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "bb54ec0f-e627-4784-85e0-0cb87178ced4",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -96,
        624
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 9
            }
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "524ac1d6-6b27-41de-a8c1-4af416c098d8",
      "name": "Aggregate",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        1488,
        1088
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData"
      },
      "typeVersion": 1
    },
    {
      "id": "e3aad525-4606-4c5f-a826-cd740ea1c7a6",
      "name": "Prepare columns for Google Sheets",
      "type": "n8n-nodes-base.set",
      "position": [
        144,
        1088
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "{\n  \"Date\": \"\",\n  \"Target\": \"\",\n  \"Backlink\": \"\",\n  \"Spam Score\": \"\",\n  \"Backlink Rank\": \"\",\n  \"Domain from\": \"\",\n  \"Domain from Rank\": \"\",\n  \"URL from\": \"\",\n  \"URL from Rank\": \"\",\n  \"Backlink Is Broken\":\"\",\n  \"Backlinks Is Dofollow\":\"\"\n}\n"
      },
      "typeVersion": 3.4
    },
    {
      "id": "fd6e2c7c-b6f8-4c0a-94c8-49149708c272",
      "name": "Prepare data for Google Sheets",
      "type": "n8n-nodes-base.set",
      "position": [
        1040,
        1088
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "={\n  \"Date\": \"{{ $now.format('yyyy-MM-dd') }}\",\n  \"Target\": \"{{ $('Get lost backlinks').item.json.tasks[0].data.target }}\",\n  \"Backlink\": \" {{ $json.url_to }}\",\n  \"Spam Score\": \"{{ $json.backlink_spam_score }}\",\n  \"Backlink Rank\": \"{{ $json.rank }}\",\n  \"Domain from\": \"{{ $json.domain_from }}\",\n  \"Domain from Rank\": \"{{ $json.domain_from_rank }}\",\n  \"URL from\": \"{{ $json.url_from }}\",\n  \"URL from Rank\": \"{{ $json.page_from_rank }}\",\n  \"Backlink Is Broken\":\"{{ $json.is_broken }}\",\n  \"Backlinks Is Dofollow\":\"{{ $json.dofollow }}\"\n}"
      },
      "typeVersion": 3.4
    },
    {
      "id": "038308b0-030d-49f3-b292-4ba0e35a69be",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -816,
        464
      ],
      "parameters": {
        "width": 400,
        "height": 496,
        "content": "This workflow runs on a scheduled basis, tracks lost backlinks via the DataForSEO Backlinks API, records them in Google Sheets, and sends daily email updates to help you detect link drops early.\n\n## How it works\n1. Triggers automatically according to the set schedule.\n2. Pulls recently lost backlinks using the DataForSEO Backlinks API.\n3. Creates or updates a Google Sheets report with the latest data.\n4. Sends an automated email with the report link.\n\n## Setup steps\n1. Create or select your DataForSEO connection (use [your API login and password](https://app.dataforseo.com/api-access)).\n2. Enter the target domain you want to monitor.\n3. Connect Google Sheets to store your backlink reports.\n4. Connect Gmail and define the recipient email address.\n"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "a4d9ec17-3846-4dce-8e79-2c128edd2363",
  "connections": {
    "Aggregate": {
      "main": [
        [
          {
            "node": "Send a message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append columns": {
      "main": [
        [
          {
            "node": "Set final \"items\" field",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Has more pages?": {
      "main": [
        [
          {
            "node": "Set \"items\" field",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Filter (has new backlinks)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split out items": {
      "main": [
        [
          {
            "node": "Prepare data for Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Initialize \"items\" field",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set \"items\" field": {
      "main": [
        [
          {
            "node": "Get lost backlinks",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create spreadsheet": {
      "main": [
        [
          {
            "node": "Prepare columns for Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get lost backlinks": {
      "main": [
        [
          {
            "node": "Merge \"items\" with DFS response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append row in sheet": {
      "main": [
        [
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set final \"items\" field": {
      "main": [
        [
          {
            "node": "Split out items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Initialize \"items\" field": {
      "main": [
        [
          {
            "node": "Set \"items\" field",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter (has new backlinks)": {
      "main": [
        [
          {
            "node": "Create spreadsheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare data for Google Sheets": {
      "main": [
        [
          {
            "node": "Append row in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge \"items\" with DFS response": {
      "main": [
        [
          {
            "node": "Has more pages?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare columns for Google Sheets": {
      "main": [
        [
          {
            "node": "Append columns",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}