{
  "name": "Extract and score Facebook Marketplace Details & Status Checker (Sold/Price) data to Google Sheets, CSV, and Slack with Apify",
  "nodes": [
    {
      "parameters": {
        "content": "## Facebook Marketplace Details & Status Checker (Sold/Price) — Automated Sheets, CSV & Slack Pipeline\n\nBuilt for market research, e-commerce, and growth teams. This workflow runs on a schedule to extract fresh data with the **[facebook-marketplace-status-checker Apify Actor](https://apify.com/unitbytes/facebook-marketplace-status-checker?fpr=939u3w&fp_sid=n8n_io)** ($0.0015 / item), skips previously seen records, scores each item, logs results to **Google Sheets** and **CSV**, and posts **Slack** alerts for top matches.\n\n### How it works\n1. **Every 6 Hours** triggers the run and loads search settings from **1. Configure Search & Rules**.\n2. **2. Run UnitBytes (facebook-marketplace-status-checker)** executes the actor via Apify's synchronous endpoint.\n3. **3. Skip Seen Records** deduplicates items by `id` across runs.\n4. **4. Clean & Score Items** and **5. Map Export Fields** normalize fields (`id, url, listing_status, is_sold, is_pending`) and compute a 0–100 `priorityScore`.\n5. **6a. Log to Google Sheets** and **6b. Export Backup CSV** store all rows, while **6c. Filter High-Priority Items** sends top matches to **7. Send Slack Alert**.\n\n### Setup\n1. Copy your API token from [facebook-marketplace-status-checker on Apify Store](https://apify.com/unitbytes/facebook-marketplace-status-checker?fpr=939u3w&fp_sid=n8n_io) into the **HTTP Header Auth** credential (`Authorization: Bearer <TOKEN>`) on node 2.\n2. Edit `actorInput`, `sheetTab`, and `maxTargetPrice` in **1. Configure Search & Rules**.\n3. Connect **Google Sheets** and **Slack** credentials (or test immediately via CSV export).\n\n### Customization\n- Tune `maxTargetPrice` or `priorityKeyword` in node 1 to adjust Slack alert sensitivity.\n- Full schema reference: [https://unitbytes.com/actors/facebook-marketplace-status-checker/](https://unitbytes.com/actors/facebook-marketplace-status-checker/)",
        "height": 760,
        "width": 560,
        "color": 1
      },
      "id": "27e39510-8712-5fe1-811c-8d04b3309fe4",
      "name": "Overview",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -640,
        -80
      ]
    },
    {
      "parameters": {
        "content": "## 1. Schedule & Search Settings\nTriggers on schedule and sets target search parameters, Google Sheets tab, and alert thresholds.",
        "height": 380,
        "width": 440,
        "color": 7
      },
      "id": "002d0afa-3231-5d06-81fc-70ab2108abca",
      "name": "Section 1 — Schedule & Settings",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        60
      ]
    },
    {
      "parameters": {
        "content": "## 2. Extract & Deduplicate\nRuns the UnitBytes Apify Actor and skips records already processed in previous runs.",
        "height": 380,
        "width": 440,
        "color": 7
      },
      "id": "c070d588-5c70-5665-a2a3-fadb2a2f9eb6",
      "name": "Section 2 — Extract & Deduplicate",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        460,
        60
      ]
    },
    {
      "parameters": {
        "content": "## 3. Clean, Score & Flatten\nNormalizes fields, parses numeric metrics, and calculates a 0–100 priority score.",
        "height": 380,
        "width": 440,
        "color": 7
      },
      "id": "73fa15cb-2a69-5529-ad9e-d37e44bff8c6",
      "name": "Section 3 — Clean, Score & Flatten",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        920,
        60
      ]
    },
    {
      "parameters": {
        "content": "## 4. Sync to Sheets, CSV & Slack\nLogs all new records to Google Sheets and CSV, and routes high-priority matches to Slack.",
        "height": 660,
        "width": 540,
        "color": 7
      },
      "id": "1d7966bd-5e1d-5a4f-9035-5c3670a97e47",
      "name": "Section 4 — Sheets, CSV & Slack",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1380,
        -80
      ]
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours",
              "hoursInterval": 6
            }
          ]
        }
      },
      "id": "7a602367-8364-5ba0-a715-0e64637a44d1",
      "name": "Every 6 Hours",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        40,
        220
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "8580e13f-5ede-503c-8c7f-0436bae53f07",
              "name": "actorInput",
              "value": "{\"start_urls\": [{\"url\": \"https://www.facebook.com/marketplace/profile/pfbid02fHmfVKi2eUKuJXquLbfyqdsSxEJaQxRUjDk2tdM1mbsNenjtTubssg4xXJzd14gil/\"}], \"max_results\": 50, \"concurrency\": 5, \"proxy_configuration\": {\"useApifyProxy\": true, \"apifyProxyGroups\": [\"RESIDENTIAL\"]}}",
              "type": "object"
            },
            {
              "id": "c2795ba4-7a99-5ecc-a377-61b606be3cc2",
              "name": "sheetTab",
              "value": "MarketplaceDeals",
              "type": "string"
            },
            {
              "id": "34f198a3-68e3-5936-9ed2-bfd499c83dfc",
              "name": "maxTargetPrice",
              "value": 500,
              "type": "number"
            },
            {
              "id": "cf9acba4-11fc-5bc5-a474-13b51c809d4e",
              "name": "priorityKeyword",
              "value": "",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "2dbaf347-145a-53c1-a59c-d3f9d1adb041",
      "name": "1. Configure Search & Rules",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        260,
        220
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.apify.com/v2/acts/unitbytes~facebook-marketplace-status-checker/run-sync-get-dataset-items?format=json&clean=true",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify($json.actorInput) }}",
        "options": {
          "timeout": 300000
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "58e4a8b3-3798-5837-9e9c-c5513711f4d1",
          "name": "Apify API Token (Header Auth)"
        }
      },
      "id": "eb375da4-faf7-5c2d-b797-0b227df3b548",
      "name": "2. Run UnitBytes (facebook-marketplace-status-checker)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        500,
        220
      ]
    },
    {
      "parameters": {
        "operation": "removeItemsSeenInPreviousExecutions",
        "dedupeValue": "={{ $json.id || $json.id || $json.url }}",
        "options": {}
      },
      "id": "bce5488d-9d38-583e-859b-29a7c6e8fdab",
      "name": "3. Skip Seen Records",
      "type": "n8n-nodes-base.removeDuplicates",
      "typeVersion": 2,
      "position": [
        720,
        220
      ]
    },
    {
      "parameters": {
        "jsCode": "// Normalize fields, parse numeric metrics, and score items for Slack alerts\nconst config = $('1. Configure Search & Rules').first().json;\nconst threshold = Number(config.maxTargetPrice ?? 500);\nconst keywordFilter = String(config.priorityKeyword || '').trim().toLowerCase();\nconst primaryKeys = [\"id\", \"url\", \"listing_status\", \"is_sold\", \"is_pending\", \"price\"];\n\nreturn $input.all().map((item) => {\n  const raw = item.json || {};\n  const cleaned = { ...raw };\n\n  for (const k of primaryKeys) {\n    if (typeof cleaned[k] === 'string') {\n      cleaned[k] = cleaned[k].replace(/\\s+/g, ' ').trim();\n    }\n  }\n\n  const recordId = String(cleaned.id || cleaned.id || cleaned.url || '');\n  const titleText = String(cleaned.title || cleaned.content || cleaned.body || cleaned.keyword || cleaned.name || cleaned.sellerNick || recordId).slice(0, 180);\n  const itemUrl = String(cleaned.url || cleaned.productUrl || cleaned.taobaoUrl || cleaned.resolved_url || cleaned.input_url || cleaned.contributor_url || '');\n  const rawMetric = cleaned.price ?? cleaned.promotionPrice ?? cleaned.priceMin ?? cleaned.score ?? cleaned.likedCount ?? cleaned.likeCount ?? cleaned.value ?? cleaned.review_stars ?? cleaned.local_guide_level ?? 0;\n  const numericValue = Number(String(rawMetric).replace(/[^0-9.-]/g, '')) || 0;\n\n  let priorityScore = 50;\n  let isHighPriority = false;\n  const mode = 'price_deal';\n\n  if (mode === 'price_deal') {\n    if (numericValue > 0 && numericValue <= threshold) {\n      priorityScore = Math.min(100, Math.round(70 + ((threshold - numericValue) / Math.max(threshold, 1)) * 30));\n      isHighPriority = true;\n    }\n  } else if (mode === 'review_audit') {\n    if (cleaned.is_removed === true || cleaned.is_edited === true || (numericValue > 0 && numericValue <= threshold)) {\n      priorityScore = 95;\n      isHighPriority = true;\n    }\n  } else {\n    if (numericValue >= threshold) {\n      priorityScore = Math.min(100, Math.round(70 + Math.min(numericValue / Math.max(threshold, 1), 3) * 10));\n      isHighPriority = true;\n    }\n  }\n\n  if (keywordFilter && titleText.toLowerCase().includes(keywordFilter)) {\n    priorityScore = Math.min(100, priorityScore + 20);\n    isHighPriority = true;\n  }\n\n  return {\n    json: {\n      ...cleaned,\n      recordId,\n      titleText,\n      itemUrl,\n      numericValue,\n      priorityScore,\n      isHighPriority,\n      alertSummary: `${titleText} (Metric: ${numericValue} | Score: ${priorityScore}/100)`,\n      scrapedAt: new Date().toISOString(),\n    },\n  };\n});"
      },
      "id": "2eb69583-6577-59d4-a67a-7fb56ea9abd8",
      "name": "4. Clean & Score Items",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        960,
        220
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "2cb7355f-1e03-50d3-b865-a651d78b7659",
              "name": "id",
              "value": "={{ $json.id }}",
              "type": "string"
            },
            {
              "id": "99a66e7a-cd3d-59f7-ab1b-47d03759df42",
              "name": "url",
              "value": "={{ $json.url }}",
              "type": "string"
            },
            {
              "id": "d3e3fd99-8453-5b55-92ce-83c4d02b5aa2",
              "name": "listing_status",
              "value": "={{ $json.listing_status }}",
              "type": "string"
            },
            {
              "id": "cdc9a8a9-c477-5988-b358-08f1bdfb6627",
              "name": "is_sold",
              "value": "={{ $json.is_sold }}",
              "type": "string"
            },
            {
              "id": "954e054b-0721-51ff-b3e8-e1617e020601",
              "name": "is_pending",
              "value": "={{ $json.is_pending }}",
              "type": "string"
            },
            {
              "id": "eecc7580-14a7-5568-bee7-8fc4c9969a2a",
              "name": "price",
              "value": "={{ $json.price }}",
              "type": "string"
            },
            {
              "id": "137c393c-27df-5898-a3e5-4f5ee63cb0fb",
              "name": "numericValue",
              "value": "={{ $json.numericValue }}",
              "type": "number"
            },
            {
              "id": "4dd04bd1-5de9-53b0-b8c6-87b6bc44d771",
              "name": "priorityScore",
              "value": "={{ $json.priorityScore }}",
              "type": "number"
            },
            {
              "id": "a9e18e61-2b9c-5340-85b7-63a9bbfe8e76",
              "name": "isHighPriority",
              "value": "={{ $json.isHighPriority }}",
              "type": "boolean"
            },
            {
              "id": "5ab0674f-2a0c-5e12-aec3-b22182084c0b",
              "name": "alertSummary",
              "value": "={{ $json.alertSummary }}",
              "type": "string"
            },
            {
              "id": "d6f47112-ae00-517a-bfbd-8ca82dbb42d1",
              "name": "scrapedAt",
              "value": "={{ $json.scrapedAt }}",
              "type": "string"
            }
          ]
        },
        "includeOtherFields": true,
        "options": {}
      },
      "id": "d0f11a9c-4492-551b-ac27-a55d11c56471",
      "name": "5. Map Export Fields",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1180,
        220
      ]
    },
    {
      "parameters": {
        "resource": "sheet",
        "operation": "append",
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "={{ $('1. Configure Search & Rules').first().json.sheetTab }}"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "id": "={{ $json.id }}",
            "url": "={{ $json.url }}",
            "listing_status": "={{ $json.listing_status }}",
            "is_sold": "={{ $json.is_sold }}",
            "is_pending": "={{ $json.is_pending }}",
            "price": "={{ $json.price }}",
            "numericValue": "={{ $json.numericValue }}",
            "priorityScore": "={{ $json.priorityScore }}",
            "isHighPriority": "={{ $json.isHighPriority }}",
            "alertSummary": "={{ $json.alertSummary }}",
            "scrapedAt": "={{ $json.scrapedAt }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "id",
              "displayName": "id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "url",
              "displayName": "url",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "listing_status",
              "displayName": "listing_status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "is_sold",
              "displayName": "is_sold",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "is_pending",
              "displayName": "is_pending",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "price",
              "displayName": "price",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "numericValue",
              "displayName": "numericValue",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "priorityScore",
              "displayName": "priorityScore",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "isHighPriority",
              "displayName": "isHighPriority",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "alertSummary",
              "displayName": "alertSummary",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "scrapedAt",
              "displayName": "scrapedAt",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ]
        },
        "options": {
          "cellFormat": "RAW"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "392f8733-93e7-5818-aa0c-b1fd35cc5d9c",
          "name": "Google Sheets account"
        }
      },
      "id": "7a80a7dc-2e0d-5534-823e-64967e197685",
      "name": "6a. Log to Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        1440,
        -20
      ]
    },
    {
      "parameters": {
        "operation": "csv",
        "options": {
          "fileName": "facebook-marketplace-status-checker-dataset-export.csv"
        }
      },
      "id": "6f18ace3-946e-5a76-b762-16bc95e93c75",
      "name": "6b. Export Backup CSV",
      "type": "n8n-nodes-base.convertToFile",
      "typeVersion": 1.1,
      "position": [
        1440,
        160
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "ecb09ae3-2685-56df-a690-548dfcc5de79",
              "leftValue": "={{ $json.isHighPriority }}",
              "rightValue": true,
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "929edf97-064f-588d-8a29-41e50b79fd46",
      "name": "6c. Filter High-Priority Items",
      "type": "n8n-nodes-base.filter",
      "typeVersion": 2.2,
      "position": [
        1440,
        360
      ]
    },
    {
      "parameters": {
        "resource": "message",
        "operation": "post",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "messageType": "text",
        "text": "=:bell: *New High-Priority Match (Facebook Marketplace Details & Status Checker (Sold/Price))*\n*<{{ $json.itemUrl }}|{{ $json.titleText }}>*\n• *Priority Score:* {{ $json.priorityScore }}/100 ({{ $json.numericValue }})\n• *Record ID:* `{{ $json.recordId }}`\n• *Scraped At:* {{ $json.scrapedAt }}",
        "otherOptions": {
          "includeLinkToWorkflow": false,
          "unfurl_links": false
        }
      },
      "credentials": {
        "slackApi": {
          "id": "6c67b0db-bde1-5e74-9d67-b43b6bfdb500",
          "name": "Slack account"
        }
      },
      "id": "8beb1bac-bf1f-5fbb-9c4b-c40d547b442c",
      "name": "7. Send Slack Alert",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.3,
      "position": [
        1680,
        360
      ]
    }
  ],
  "connections": {
    "Every 6 Hours": {
      "main": [
        [
          {
            "node": "1. Configure Search & Rules",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "1. Configure Search & Rules": {
      "main": [
        [
          {
            "node": "2. Run UnitBytes (facebook-marketplace-status-checker)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "2. Run UnitBytes (facebook-marketplace-status-checker)": {
      "main": [
        [
          {
            "node": "3. Skip Seen Records",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "3. Skip Seen Records": {
      "main": [
        [
          {
            "node": "4. Clean & Score Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "4. Clean & Score Items": {
      "main": [
        [
          {
            "node": "5. Map Export Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "5. Map Export Fields": {
      "main": [
        [
          {
            "node": "6a. Log to Google Sheets",
            "type": "main",
            "index": 0
          },
          {
            "node": "6b. Export Backup CSV",
            "type": "main",
            "index": 0
          },
          {
            "node": "6c. Filter High-Priority Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "6c. Filter High-Priority Items": {
      "main": [
        [
          {
            "node": "7. Send Slack Alert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "meta": {
    "templateCredsSetupCompleted": false,
    "instanceId": "030f9420-0ca8-5240-8fe8-208e287a8b19"
  },
  "tags": [
    {
      "name": "Web Scraping"
    },
    {
      "name": "Apify"
    },
    {
      "name": "UnitBytes"
    },
    {
      "name": "Classifieds & Local Data"
    }
  ]
}