{
  "id": "RwLw7ouriy4krW80",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Track broken backlinks with DataForSEO and create recovery tasks in Asana",
  "tags": [],
  "nodes": [
    {
      "id": "7f8c435d-10a9-4027-ba22-fb18533f6570",
      "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": "fc500366-9db1-4c63-a0f4-bc8584573ae5",
      "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": "ab04ec64-dbf2-4542-a7cb-651563bd9215",
      "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": "055b24e8-0dd1-4f88-81ab-eac51b237913",
      "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": "48435c6d-0d1b-4fd5-86fe-1a14c6998044",
      "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": "7fd35cd7-446d-40e0-ac3a-555bda55d059",
      "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": "e5e4ec71-58f9-45ca-9229-45101102f0bb",
      "name": "Split out items",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        816,
        1088
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "items"
      },
      "typeVersion": 1
    },
    {
      "id": "734eecdd-11c8-409f-bcea-efbec557c2ca",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        80,
        448
      ],
      "parameters": {
        "color": 6,
        "width": 1120,
        "height": 352,
        "content": "## Get broken backlinks with DataForSEO\nCreate a DataForSEO connection, specify a Target Domain, and set up additional parameters if needed."
      },
      "typeVersion": 1
    },
    {
      "id": "af153429-d1ff-4610-b43f-88e9b42f936f",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -336,
        896
      ],
      "parameters": {
        "color": 6,
        "width": 2160,
        "height": 384,
        "content": "## Log broken backlinks to Google Sheets and create an Asana task\nCreate a Google Sheets connection.\nCreate an Asana connection and select your Workspace ID, Project, Assignee ID, and other fields you need."
      },
      "typeVersion": 1
    },
    {
      "id": "4c3c5184-a071-428e-ab00-43bf8e312d66",
      "name": "Get lost backlinks",
      "type": "n8n-nodes-dataforseo.dataForSeoBacklinksApi",
      "position": [
        576,
        544
      ],
      "parameters": {
        "limit": 1000,
        "offset": "={{ $runIndex * 1000 }}",
        "target": "=dataforseo.com",
        "filters": "=[\"is_broken\", \"=\", true]",
        "operation": "get-backlinks"
      },
      "credentials": {
        "dataForSeoApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "4f8401a1-1b56-44ed-9ec6-b74b4d05acf0",
      "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": "00785c02-6bff-4798-932d-cb5f90756fb4",
      "name": "Create spreadsheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -80,
        1088
      ],
      "parameters": {
        "title": "=Broken Backlinks for  {{ $('Get lost backlinks').item.json.tasks[0].data.target }}",
        "options": {},
        "resource": "spreadsheet",
        "sheetsUi": {
          "sheetValues": [
            {
              "title": "Broken Backlinks"
            }
          ]
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "3a4cee16-11c0-4d7f-abdb-12afeee42ed8",
      "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": "0c909100-6afc-4344-b1a4-c17096bb11ea",
      "name": "Create a task",
      "type": "n8n-nodes-base.asana",
      "position": [
        1696,
        1088
      ],
      "parameters": {
        "name": "=Broken backlinks for {{ $('Get lost backlinks').item.json.tasks[0].data.target }}",
        "workspace": "112670807337085",
        "otherProperties": {
          "notes": "=Broken Backlinks for {{ $('Get lost backlinks').item.json.tasks[0].data.target }}: {{ $('Create spreadsheet').item.json.spreadsheetUrl }}",
          "assignee": "1207548230460014",
          "projects": [
            "1207548+1234567890"
          ]
        }
      },
      "credentials": {
        "asanaApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "f04a6484-27ee-49cd-a073-d399711ddf5d",
      "name": "Aggregate",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        1488,
        1088
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData"
      },
      "typeVersion": 1
    },
    {
      "id": "b697b3f9-7fbc-4a62-a39d-c60d48c47841",
      "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": "71ee2b44-c9c6-466a-bd0c-1bf7782b253f",
      "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": "161ad09a-ed85-493b-b25a-321a5560c172",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -64,
        624
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "weeks",
              "triggerAtDay": [
                1
              ],
              "triggerAtHour": 9
            }
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "d520e785-4bdc-4d36-b996-dc217becd11c",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -896,
        464
      ],
      "parameters": {
        "width": 480,
        "height": 512,
        "content": "This workflow runs on a scheduled basis, tracks broken backlinks via the DataForSEO Backlinks API, and records them in Google Sheets to help you quickly detect and fix link issues affecting your SEO performance.\n\n## How it works\n1. Triggers automatically according to the set schedule.\n2. Pulls recently detected broken backlinks using the DataForSEO Backlinks API.\n3. Creates or updates a Google Sheets report with the latest link data.\n4. Creates a relevant Asana task.\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 reports.\n4. Set up an Asana connection, select your Workspace, and task Assignee.\n"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "75b95ea8-2f71-4aef-9df4-c3ee45ab67db",
  "connections": {
    "Aggregate": {
      "main": [
        [
          {
            "node": "Create a task",
            "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
          }
        ]
      ]
    }
  }
}