{
  "id": "y0Yk7da21T4u9zlp",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "My workflow 23",
  "tags": [],
  "nodes": [
    {
      "id": "7b9d2ce1-ea1d-4ef6-bc7e-398295c537c7",
      "name": "Daily Regulatory Poll",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        112,
        752
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours",
              "hoursInterval": 24
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "66a15fbc-f403-4038-a39e-41e1f7de9cd2",
      "name": "\ud83d\udcdd Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -560,
        288
      ],
      "parameters": {
        "color": 7,
        "width": 520,
        "height": 540,
        "content": "## How it works\n\nDaily trigger iterates through SEC, FINRA, and ESMA URLs generated in `Regulatory Sources`. Each URL runs through Split in Batches so ScrapeGraphAI fetches structured `updates`. Code nodes flatten responses and drop entries older than 24h before branching to Sheets and Slack. Sheets captures every record; Slack alerts only when fresh updates exist, giving compliance a single view of overnight regulatory actions.\n\n## Setup steps\n\n1. Set the Schedule Trigger timezone/start hour to match your team.\n2. Update the URL list if you monitor additional regulators.\n3. Add ScrapeGraphAI credentials and tweak the prompt for extra fields.\n4. Connect Google Sheets (document + sheet) plus Slack credentials/channel.\n5. Run once manually to confirm data, then enable the workflow."
      },
      "typeVersion": 1
    },
    {
      "id": "469a476b-5ef9-4a1d-9d75-afab04f8a8f4",
      "name": "Regulatory Sources",
      "type": "n8n-nodes-base.code",
      "position": [
        368,
        752
      ],
      "parameters": {
        "jsCode": "/* Generate list of regulatory source URLs */\nconst urls = [\n  'https://www.sec.gov/news/pressreleases',\n  'https://www.finra.org/rules-guidance/notices',\n  'https://www.esma.europa.eu/press-news'\n];\n\nreturn urls.map(url => ({\n  json: {\n    url,\n    agency: url.includes('sec.gov') ? 'SEC' : url.includes('finra.org') ? 'FINRA' : 'ESMA'\n  }\n}));"
      },
      "typeVersion": 2
    },
    {
      "id": "d065ff5f-fc3a-40ac-8dc3-9a2ca329f0bf",
      "name": "Split URLs",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        608,
        752
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "80c1c748-748a-44cd-b532-2b94631fb566",
      "name": "Source Intake Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        96,
        528
      ],
      "parameters": {
        "color": 7,
        "width": 648,
        "height": 492,
        "content": "## Source Intake\nDaily trigger, Regulatory Sources, and Split in Batches define which agency URLs run and feed the scraper sequentially."
      },
      "typeVersion": 1
    },
    {
      "id": "5068df3e-55f1-4152-b905-b129708ed967",
      "name": "Scrape Regulatory Updates",
      "type": "n8n-nodes-scrapegraphai.scrapegraphAi",
      "position": [
        864,
        752
      ],
      "parameters": {
        "userPrompt": "Extract the five most recent regulatory or compliance updates from this page. Respond in JSON with the following schema: {\"updates\": [{\"title\": \"string\", \"summary\": \"string\", \"date\": \"ISO_DATE\", \"agency\": \"string\", \"source_url\": \"string\"}]}. If no updates are found, return {\"updates\": []}.",
        "websiteUrl": "={{ $json.url }}"
      },
      "typeVersion": 1
    },
    {
      "id": "370824c9-5c46-49b8-b2c2-f28e56da9488",
      "name": "Processing & Filter Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        832,
        496
      ],
      "parameters": {
        "color": 7,
        "width": 632,
        "height": 524,
        "content": "## Processing & Filter\nScrapeGraphAI pulls structured updates, then Flatten Updates and Filter Recent keep only readable, last-24h entries."
      },
      "typeVersion": 1
    },
    {
      "id": "8b0ca40f-0e52-4ecd-931a-91959997568c",
      "name": "Flatten Updates",
      "type": "n8n-nodes-base.code",
      "position": [
        1120,
        752
      ],
      "parameters": {
        "jsCode": "// Flatten the array of updates into individual items\nconst output = [];\nfor (const item of $input.all()) {\n  const agency = item.json.agency;\n  const updates = item.json.updates || [];\n  for (const update of updates) {\n    output.push({\n      json: {\n        title: update.title || '',\n        summary: update.summary || '',\n        date: update.date || '',\n        agency: update.agency || agency,\n        source_url: update.source_url || item.json.url,\n        scraped_at: new Date().toISOString()\n      }\n    });\n  }\n}\nreturn output;"
      },
      "typeVersion": 2
    },
    {
      "id": "375806c1-b4e3-44ec-864a-007b42472358",
      "name": "Filter Recent Updates",
      "type": "n8n-nodes-base.code",
      "position": [
        1360,
        752
      ],
      "parameters": {
        "jsCode": "// Keep only updates from last 24 hours\nconst ONE_DAY_MS = 24 * 60 * 60 * 1000;\nconst now = Date.now();\nreturn $input.all().filter(item => {\n  const dateMs = Date.parse(item.json.date);\n  if (isNaN(dateMs)) return false; // discard if date unreadable\n  return now - dateMs <= ONE_DAY_MS;\n});"
      },
      "typeVersion": 2
    },
    {
      "id": "71b727ed-0906-4e3d-b328-4cd1067e2b43",
      "name": "Log to Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1616,
        656
      ],
      "parameters": {
        "columns": {
          "value": {
            "Date": "={{ $json.date }}",
            "Title": "={{ $json.title }}",
            "Agency": "={{ $json.agency }}",
            "Summary": "={{ $json.summary }}",
            "Scraped At": "={{ $json.scraped_at }}",
            "Source URL": "={{ $json.source_url }}"
          },
          "mappingMode": "defineBelow"
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "RegUpdates"
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": "{{YOUR_SPREADSHEET_ID}}"
        }
      },
      "typeVersion": 4
    },
    {
      "id": "29fc9935-d9f8-49c1-88ce-9aed6e75d373",
      "name": "Send Compliance Alert",
      "type": "n8n-nodes-base.slack",
      "position": [
        1616,
        848
      ],
      "parameters": {
        "operation": "postMessage"
      },
      "typeVersion": 2
    },
    {
      "id": "1d9b07f9-819f-4dda-b7ac-c0b5918f0499",
      "name": "Delivery Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1520,
        448
      ],
      "parameters": {
        "color": 7,
        "width": 360,
        "height": 572,
        "content": "## Delivery\nGoogle Sheets archives every saved row, while Slack alerts compliance whenever new regulatory items pass the filter."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "3014ef9e-cd92-4d13-ae90-4309ac4367e4",
  "connections": {
    "Split URLs": {
      "main": [
        [
          {
            "node": "Scrape Regulatory Updates",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Flatten Updates": {
      "main": [
        [
          {
            "node": "Filter Recent Updates",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Regulatory Sources": {
      "main": [
        [
          {
            "node": "Split URLs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Daily Regulatory Poll": {
      "main": [
        [
          {
            "node": "Regulatory Sources",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Recent Updates": {
      "main": [
        [
          {
            "node": "Log to Google Sheets",
            "type": "main",
            "index": 0
          },
          {
            "node": "Send Compliance Alert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Scrape Regulatory Updates": {
      "main": [
        [
          {
            "node": "Flatten Updates",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}