{
  "name": "Startup funding to research sheet (NexGen Signal)",
  "nodes": [
    {
      "parameters": {
        "jsCode": "\nconst unknownMessage = (at) => `START OUTCOME UNKNOWN: a request to start a paid run was sent at ${at} but no answer `\n  + `came back, so it is not known whether Apify started it. This workflow will not start another run until you decide. `\n  + `Check Apify Console > Runs for nexgensignal/funding-round-intelligence-api around that time. If a run is there, paste its run ID into `\n  + `resumeRunId in Settings (its results are collected without paying again). If no run started, paste ${at} into `\n  + `startNewAfterUnknown.`;\n// Edit these, then save. Charges: $0.02 start fee per run (2 GB) + each record delivered.\nconst settings = {\n  daysBack: 7,                        // weekly schedule reads the last 7 days\n  includePrNewswire: true,            // adds PR Newswire releases with named investor organisations\n  industryGroups: ['Other Technology', 'Computers', 'Biotechnology', 'Pharmaceuticals', 'Other Health Care'],\n                                      // limits SEC Form D filings only; [] = every industry. News is any sector.\n  minAmount: 0,                       // e.g. 5000000 keeps only events with a known amount of $5M or more\n  searchQuery: '',                    // optional company or keyword filter\n  maxResults: 25,                     // most records (and record charges) per run\n  maxTotalChargeUsd: 2.50,            // hard spending cap for one run, start fee included\n};\n\n// ---- Recovery (normally leave empty) -------------------------------------------------------------------------\nconst recovery = {\n  resumeRunId: '',            // collect an existing run's results without starting a new paid run\n  startNewAfterUnknown: '',   // after \"START OUTCOME UNKNOWN\": paste the time it shows, if you checked no run started\n};\nconst memory = $getWorkflowStaticData('global');   // kept between executions (n8n stores it with the workflow)\nmemory.usedResumeIds = memory.usedResumeIds || [];\nif (recovery.resumeRunId && !memory.usedResumeIds.includes(recovery.resumeRunId)) {\n  memory.usedResumeIds.push(recovery.resumeRunId);\n  memory.pendingRun = recovery.resumeRunId; memory.startAttempt = null;\n}\nif (memory.startAttempt && !memory.pendingRun) {\n  if (recovery.startNewAfterUnknown !== memory.startAttempt.at) throw new Error(unknownMessage(memory.startAttempt.at));\n  memory.startAttempt = null;\n}\n\nif (memory.pendingRun) return [{ json: { mode: 'resume', runId: memory.pendingRun } }];\nconst actorInput = { mode: 'all_sources', includePrNewswire: settings.includePrNewswire,\n                     daysBack: settings.daysBack, maxResults: settings.maxResults };\nif (settings.industryGroups.length) actorInput.industryGroups = settings.industryGroups;\nif (settings.minAmount) actorInput.minAmount = settings.minAmount;\nif (settings.searchQuery) actorInput.searchQuery = settings.searchQuery;\nreturn [{ json: { mode: 'start', actorInput, maxTotalChargeUsd: settings.maxTotalChargeUsd } }];\n"
      },
      "id": "b9dcf9d0-4af9-48ee-a2af-c64059529cc0",
      "name": "Settings (edit me)",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        0,
        220
      ]
    },
    {
      "parameters": {},
      "id": "ce16028a-9e8e-442c-be9b-19cf399d7cbf",
      "name": "Run now (manual)",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        -220,
        120
      ]
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 8 * * 1"
            }
          ]
        }
      },
      "id": "5c74cee2-ab5c-40a0-b6f8-ac672c593b30",
      "name": "Mondays 08:00",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        -220,
        320
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "fc6f9a7b-2aa1-4aab-a9da-6fc5dd3a872c",
              "leftValue": "={{ $json.mode === 'resume' }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "c163b6a9-18c2-4dd2-8fd4-690c3d2449ae",
      "name": "Resume a saved run?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        220,
        220
      ]
    },
    {
      "parameters": {
        "method": "GET",
        "url": "=https://api.apify.com/v2/actor-runs/{{ $json.runId }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "options": {
          "timeout": 120000
        }
      },
      "id": "a33e0999-24c7-46af-9328-23eb4e9becf3",
      "name": "Get saved run",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        440,
        80
      ],
      "credentials": {
        "httpHeaderAuth": {
          "id": "REPLACE_WITH_YOUR_CREDENTIAL",
          "name": "Apify API token"
        }
      },
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 5000
    },
    {
      "parameters": {
        "jsCode": "const memory = $getWorkflowStaticData('global');\nmemory.startAttempt = { at: new Date().toISOString(), input: $input.first().json.actorInput };\nreturn $input.all();"
      },
      "id": "e8298924-d8d3-4575-8954-c80eb56af494",
      "name": "Record start attempt",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        440,
        280
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.apify.com/v2/acts/nexgensignal~funding-round-intelligence-api/runs",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "options": {
          "timeout": 120000
        },
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "waitForFinish",
              "value": "60"
            },
            {
              "name": "maxTotalChargeUsd",
              "value": "={{ $json.maxTotalChargeUsd }}"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify($json.actorInput) }}"
      },
      "id": "ae067694-c2d7-4e7b-b4a4-0dc04dd04774",
      "name": "Start Apify run",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        660,
        280
      ],
      "credentials": {
        "httpHeaderAuth": {
          "id": "REPLACE_WITH_YOUR_CREDENTIAL",
          "name": "Apify API token"
        }
      },
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "jsCode": "const memory = $getWorkflowStaticData('global');\nmemory.pendingRun = $json.data.id;\nmemory.startAttempt = null;\nreturn $input.all();"
      },
      "id": "71493636-0fa9-49e9-ba00-01ca159ea5cb",
      "name": "Remember run ID",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        880,
        220
      ]
    },
    {
      "parameters": {
        "jsCode": "\nconst unknownMessage = (at) => `START OUTCOME UNKNOWN: a request to start a paid run was sent at ${at} but no answer `\n  + `came back, so it is not known whether Apify started it. This workflow will not start another run until you decide. `\n  + `Check Apify Console > Runs for nexgensignal~funding-round-intelligence-api around that time. If a run is there, paste its run ID into `\n  + `resumeRunId in Settings (its results are collected without paying again). If no run started, paste ${at} into `\n  + `startNewAfterUnknown.`;\n\nconst memory = $getWorkflowStaticData('global');\nconst e = $json.error || {};\nconst status = Number(e.httpCode || e.status || (String(e.message || '').match(/\\b([45]\\d\\d)\\b/) || [])[1] || 0);\nif (status >= 400 && status < 500) {          // Apify answered with a refusal: no run was started\n  if (memory.startAttempt && memory.startAttempt.plan) {\n    let kind = null; try { kind = $('Record start attempt').itemMatching(0).json.kind; } catch (err) {}\n    memory.startAttempt.plan = memory.startAttempt.plan.filter(p => p.kind !== kind);\n    if (!memory.startAttempt.plan.length) memory.startAttempt = null;\n  } else { memory.startAttempt = null; }\n  return [{ json: { message: `Apify refused to start the run (HTTP ${status}): ${e.message || ''} Nothing was started.` } }];\n}\n// (no throw here: n8n keeps changes to saved memory only when the node itself succeeds; the next node stops)\nreturn [{ json: { message: unknownMessage(memory.startAttempt ? memory.startAttempt.at : 'unknown time') } }];\n"
      },
      "id": "5adb3595-5dc1-4bdf-a241-830a099f3e82",
      "name": "Start outcome unknown",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        880,
        420
      ]
    },
    {
      "parameters": {
        "errorMessage": "={{ $json.message }}"
      },
      "id": "2bf548bd-dc8b-428f-9741-a15f36c67297",
      "name": "Stop: start problem",
      "type": "n8n-nodes-base.stopAndError",
      "typeVersion": 1,
      "position": [
        1100,
        420
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "c05b698d-d977-4aed-9a09-1047edf4030a",
              "leftValue": "={{ $input.all().some(i => ['READY','RUNNING','TIMING-OUT','ABORTING'].includes(i.json.data.status)) }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "137291a0-0cf3-4602-84a9-e824a66f66e1",
      "name": "Still running?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        1100,
        220
      ]
    },
    {
      "parameters": {
        "amount": 5,
        "unit": "seconds"
      },
      "id": "9f998dea-2ed4-4430-b5ce-232c0ebddd05",
      "name": "Wait 5 s",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        1320,
        60
      ],
      "webhookId": "8c72c68b-05d9-45db-a22f-f30759177577"
    },
    {
      "parameters": {
        "method": "GET",
        "url": "=https://api.apify.com/v2/actor-runs/{{ $json.data.id }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "options": {
          "timeout": 120000
        },
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "waitForFinish",
              "value": "60"
            }
          ]
        }
      },
      "id": "1be02afa-6bf8-4625-be02-5ed10d6c03e5",
      "name": "Check run",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1540,
        60
      ],
      "credentials": {
        "httpHeaderAuth": {
          "id": "REPLACE_WITH_YOUR_CREDENTIAL",
          "name": "Apify API token"
        }
      },
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 5000
    },
    {
      "parameters": {},
      "id": "77f542f1-7657-47b1-98f6-aa36867a8e0a",
      "name": "Run finished",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1320,
        280
      ]
    },
    {
      "parameters": {
        "method": "GET",
        "url": "https://api.apify.com/v2/acts/nexgensignal~funding-round-intelligence-api/runs",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "options": {
          "timeout": 120000
        },
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "desc",
              "value": "1"
            },
            {
              "name": "limit",
              "value": "25"
            }
          ]
        }
      },
      "id": "0264aeef-c701-41cf-b136-5bd3e7405458",
      "name": "List runs of this Actor",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        330,
        520
      ],
      "credentials": {
        "httpHeaderAuth": {
          "id": "REPLACE_WITH_YOUR_CREDENTIAL",
          "name": "Apify API token"
        }
      },
      "executeOnce": true,
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 5000
    },
    {
      "parameters": {
        "jsCode": "\n// Runs of this Actor that are still going (READY / RUNNING / TIMING-OUT), newest first.\nconst going = ['READY', 'RUNNING', 'TIMING-OUT'];\nconst items = (($json.data || {}).items || []).filter(r => going.includes(r.status));\nif (!items.length) return [{ json: { none: true } }];\nreturn items.map(r => ({ json: { runId: r.id, kv: r.defaultKeyValueStoreId, startedAt: r.startedAt } }));\n"
      },
      "id": "7db93656-3875-4ab7-8cd7-a656bc35689b",
      "name": "Runs still going",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        550,
        520
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "84e80f83-b98a-4a23-a528-c89a6e235219",
              "leftValue": "={{ !$json.none }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "af813d48-d1a7-40e9-b5fc-8c71e76c5a33",
      "name": "Another run going?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        770,
        520
      ]
    },
    {
      "parameters": {
        "method": "GET",
        "url": "=https://api.apify.com/v2/key-value-stores/{{ $json.kv }}/records/INPUT",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "options": {
          "timeout": 120000
        }
      },
      "id": "344192f6-ae87-4a6b-9974-7385c0835160",
      "name": "Read input of running runs",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        990,
        460
      ],
      "credentials": {
        "httpHeaderAuth": {
          "id": "REPLACE_WITH_YOUR_CREDENTIAL",
          "name": "Apify API token"
        }
      },
      "alwaysOutputData": true,
      "onError": "continueRegularOutput",
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 5000
    },
    {
      "parameters": {
        "jsCode": "\n// The run this execution would start: the 'start' items planned in 'Settings (edit me)'.\nconst planned = $('Settings (edit me)').all().map(it => ({ json: it.json })).filter(x => x.json.mode === 'start');\nlet running = [];\ntry { running = $('Read input of running runs').all().map(i => i.json || {}); } catch (e) { running = []; }\nlet ids = [];\ntry { ids = $('Runs still going').all().map(i => i.json); } catch (e) { ids = []; }\n// Same settings = every setting this execution would send has the same value in the running run's input\n// (Apify may add the Actor's defaults to a run's stored input, so extra fields there do not matter).\nconst same = (mine, theirs) => Object.keys(mine).every(k => JSON.stringify(mine[k]) === JSON.stringify(theirs[k]));\nfor (const p of planned) {\n  const i = running.findIndex(inp => inp && typeof inp === 'object' && same(p.json.actorInput || {}, inp));\n  if (i >= 0) {\n    const r = ids[i] || {};\n    return [{ json: { __overlap: `ALREADY RUNNING: run ${r.runId || ''} of this Actor, started ${r.startedAt || ''} with `\n      + `the same settings, is still going (most likely started by an earlier execution of this workflow that is `\n      + `still waiting for it). This execution stopped without starting or paying for anything; the earlier `\n      + `execution writes those results. If that earlier execution was stopped, its run is not collected `\n      + `automatically: paste its run ID into resumeRunId in Settings.` } }];\n  }\n}\nreturn planned;\n"
      },
      "id": "172f4e74-0dcc-4db7-ad10-6fda7f634b7c",
      "name": "Same settings already running?",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1210,
        520
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "7d29e426-f822-449b-a18f-eb605553f6bd",
              "leftValue": "={{ !!$json.__overlap }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "d58c5a6e-ba29-452c-a085-2ae571fced17",
      "name": "Overlap?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        1430,
        520
      ]
    },
    {
      "parameters": {
        "errorMessage": "={{ $json.__overlap }}"
      },
      "id": "c14b20fe-2cc6-48ab-89f1-25da0fc687a7",
      "name": "Stop: already running",
      "type": "n8n-nodes-base.stopAndError",
      "typeVersion": 1,
      "position": [
        1650,
        460
      ]
    },
    {
      "parameters": {
        "method": "GET",
        "url": "=https://api.apify.com/v2/key-value-stores/{{ $json.data.defaultKeyValueStoreId }}/records/RUN_RECEIPT",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "options": {
          "timeout": 120000
        }
      },
      "id": "2045f42a-bef9-4a75-955f-7ee9283ac0a2",
      "name": "Get run receipt",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1540,
        280
      ],
      "credentials": {
        "httpHeaderAuth": {
          "id": "REPLACE_WITH_YOUR_CREDENTIAL",
          "name": "Apify API token"
        }
      },
      "alwaysOutputData": true,
      "onError": "continueRegularOutput",
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 5000
    },
    {
      "parameters": {
        "method": "GET",
        "url": "=https://api.apify.com/v2/datasets/{{ $('Run finished').item.json.data.defaultDatasetId }}/items",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "options": {
          "timeout": 120000
        },
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "clean",
              "value": "true"
            },
            {
              "name": "format",
              "value": "json"
            }
          ]
        }
      },
      "id": "6b98648f-6a45-46c1-9b5c-62b0ded8d122",
      "name": "Get records",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1760,
        280
      ],
      "credentials": {
        "httpHeaderAuth": {
          "id": "REPLACE_WITH_YOUR_CREDENTIAL",
          "name": "Apify API token"
        }
      },
      "alwaysOutputData": true,
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 5000
    },
    {
      "parameters": {
        "jsCode": "\nfunction outcome(run, n) {\n  const msg = run.statusMessage || '';\n  if (run.status !== 'SUCCEEDED') return 'failed';\n  if (msg.startsWith('SOURCE UNAVAILABLE')) return 'source_unavailable';\n  if (/^(PARTIAL|CAPPED|INCOMPLETE SEARCH)/.test(msg) || msg.includes('PARTIAL SEARCH')\n      || msg.startsWith('The sources that answered')) return 'partial';\n  return n === 0 ? 'no_match' : 'complete';\n}\n\nconst run = $('Run finished').first().json.data;\nconst receipt = $('Get run receipt').first().json || {};\nconst n = $('Get records').all().filter(i => i.json && i.json.record_id).length;\nconst resumed = $('Settings (edit me)').first().json.mode === 'resume';\nreturn [{ json: { run_at: new Date().toISOString(), run_id: run.id, outcome: outcome(run, n), records_received: n,\n                  charged_records: receipt.delivered ?? '', status_message: run.statusMessage || '',\n                  note: resumed ? 'results of a run started earlier (no new charge)' : '' } }];\n"
      },
      "id": "56df81b6-0baf-4ad6-864c-317d2f32507b",
      "name": "Run log entry",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1980,
        280
      ]
    },
    {
      "parameters": {
        "jsCode": "\nconst s = v => v === null || v === undefined ? '' : String(v);\nconst names = (v, withRole) => (v || []).map(x => typeof x === 'object' && x\n  ? (withRole && x.role ? `${x.name} (${x.role})` : x.name) : String(x)).filter(Boolean).join('; ');\nconst now = new Date().toISOString();\nreturn $('Get records').all().map(i => i.json).filter(r => r && r.record_id).map(r => {\n  const refs = (r.source_references || []).filter(x => x.record_id !== r.record_id);\n  return { json: {\n    record_id: r.record_id, date: s(r.date), company_name: s(r.company_name), source: s(r.source),\n    event_type: s(r.event_type), raise_status: s(r.raise_status), financing_type: s(r.financing_type),\n    amount: s(r.amount), currency: s(r.currency), amount_type: s(r.amount_type),\n    amount_display: s(r.amount_display), round_stage: s(r.round_stage),\n    lead_investors: names(r.lead_investors), investor_organizations: names(r.investor_organizations, true),\n    investor_info_status: s(r.investor_info_status), industry: s(r.industry), location: s(r.location),\n    issuer: s(r.issuer), title: s(r.title), url: s(r.url),\n    other_reports: refs.map(x => `${x.source}: ${x.url}`).join(' | '), cik: s(r.cik), last_seen: now } };\n});\n"
      },
      "id": "383412c4-9347-4e13-983f-0b4a8c96d623",
      "name": "Map records to sheet rows",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        2420,
        280
      ],
      "alwaysOutputData": true
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "ce3be097-f1f0-4339-a784-fe98a824f84f",
              "leftValue": "={{ !!$json.record_id }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "c4c8e349-2160-4d8e-8660-07793634cc12",
      "name": "Any rows?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        2640,
        280
      ]
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": "PASTE_YOUR_GOOGLE_SHEET_URL_HERE"
        },
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "Run log"
        },
        "operation": "append",
        "columns": {
          "mappingMode": "autoMapInputData",
          "value": {},
          "matchingColumns": [],
          "schema": [
            {
              "id": "run_at",
              "displayName": "run_at",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "run_id",
              "displayName": "run_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "outcome",
              "displayName": "outcome",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "records_received",
              "displayName": "records_received",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "charged_records",
              "displayName": "charged_records",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "status_message",
              "displayName": "status_message",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "note",
              "displayName": "note",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ]
        },
        "options": {
          "cellFormat": "RAW"
        }
      },
      "id": "bf06303d-ae06-44a3-b992-d6f9752d6c72",
      "name": "Run log (sheet)",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        2200,
        280
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "REPLACE_WITH_YOUR_CREDENTIAL",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": "PASTE_YOUR_GOOGLE_SHEET_URL_HERE"
        },
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "Funding"
        },
        "operation": "appendOrUpdate",
        "columns": {
          "mappingMode": "autoMapInputData",
          "value": {},
          "matchingColumns": [
            "record_id"
          ],
          "schema": [
            {
              "id": "record_id",
              "displayName": "record_id",
              "required": false,
              "defaultMatch": true,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "date",
              "displayName": "date",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "company_name",
              "displayName": "company_name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "source",
              "displayName": "source",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "event_type",
              "displayName": "event_type",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "raise_status",
              "displayName": "raise_status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "financing_type",
              "displayName": "financing_type",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "amount",
              "displayName": "amount",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "currency",
              "displayName": "currency",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "amount_type",
              "displayName": "amount_type",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "amount_display",
              "displayName": "amount_display",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "round_stage",
              "displayName": "round_stage",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "lead_investors",
              "displayName": "lead_investors",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "investor_organizations",
              "displayName": "investor_organizations",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "investor_info_status",
              "displayName": "investor_info_status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "industry",
              "displayName": "industry",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "location",
              "displayName": "location",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "issuer",
              "displayName": "issuer",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "title",
              "displayName": "title",
              "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": "other_reports",
              "displayName": "other_reports",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "cik",
              "displayName": "cik",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "last_seen",
              "displayName": "last_seen",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ]
        },
        "options": {
          "cellFormat": "RAW"
        }
      },
      "id": "59459aae-ea58-43f9-9730-d9c6a69ce9e2",
      "name": "Funding research (sheet)",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        2860,
        160
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "REPLACE_WITH_YOUR_CREDENTIAL",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "\n// Runs only after the rows were written (or there were none): forget the run.\nconst memory = $getWorkflowStaticData('global');\nmemory.pendingRun = null;\nreturn [{ json: $('Run log entry').first().json }];\n"
      },
      "id": "75e2d94c-691c-4e22-bed2-7cb5c45c09c5",
      "name": "Save progress",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        3080,
        280
      ],
      "executeOnce": true
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "0e97e682-1a92-4e08-9aa2-7beefc198fc6",
              "leftValue": "={{ ['failed','source_unavailable'].includes($json.outcome) }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "8217b14c-2889-41f1-82e3-b560824cf0d7",
      "name": "Run failed?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        3300,
        280
      ]
    },
    {
      "parameters": {
        "errorMessage": "={{ 'Apify run ' + $json.run_id + ' ended as ' + $json.outcome + ': ' + $json.status_message }}"
      },
      "id": "5382ca58-c54f-4f90-8961-f37cd89e649d",
      "name": "Stop: run failed",
      "type": "n8n-nodes-base.stopAndError",
      "typeVersion": 1,
      "position": [
        3520,
        280
      ]
    },
    {
      "parameters": {
        "content": "## Funding announcements \u2192 research sheet\nSEC Form D filings, TechCrunch funding news and PR Newswire funding releases (with named investor organisations where the release states them) via **nexgensignal/funding-round-intelligence-api**.\n\n1. Create an **Apify API token** credential: *Header Auth*, name `Authorization`, value `Bearer <your token>`; select it in the seven HTTP Request nodes.\n2. Make a Google Sheet with tabs **Funding** and **Run log**; paste the header rows from the tutorial.\n3. Paste the sheet URL into both sheet nodes and pick your Google credential.\n4. Edit **Settings (edit me)**, run once, then activate the Monday schedule.\n\nRows are matched on `record_id`, so a financing is never listed twice \u2014 but a financing delivered again (for example by overlapping date windows) is charged again. Cost per run: $0.02 start fee + $0.08 per record on the Free plan ($0.072 Bronze, $0.064 Silver, $0.0536 Gold+).",
        "height": 380,
        "width": 600,
        "color": 4
      },
      "id": "f850c8c4-6607-4528-b4a6-460f2a34a53f",
      "name": "Note 226afc",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -260,
        -300
      ]
    }
  ],
  "connections": {
    "Run now (manual)": {
      "main": [
        [
          {
            "node": "Settings (edit me)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Mondays 08:00": {
      "main": [
        [
          {
            "node": "Settings (edit me)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Start outcome unknown": {
      "main": [
        [
          {
            "node": "Stop: start problem",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Settings (edit me)": {
      "main": [
        [
          {
            "node": "Resume a saved run?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Resume a saved run?": {
      "main": [
        [
          {
            "node": "Get saved run",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "List runs of this Actor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "List runs of this Actor": {
      "main": [
        [
          {
            "node": "Runs still going",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Runs still going": {
      "main": [
        [
          {
            "node": "Another run going?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Another run going?": {
      "main": [
        [
          {
            "node": "Read input of running runs",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Same settings already running?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read input of running runs": {
      "main": [
        [
          {
            "node": "Same settings already running?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Same settings already running?": {
      "main": [
        [
          {
            "node": "Overlap?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Overlap?": {
      "main": [
        [
          {
            "node": "Stop: already running",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Record start attempt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Record start attempt": {
      "main": [
        [
          {
            "node": "Start Apify run",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Start Apify run": {
      "main": [
        [
          {
            "node": "Remember run ID",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Start outcome unknown",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get saved run": {
      "main": [
        [
          {
            "node": "Still running?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Remember run ID": {
      "main": [
        [
          {
            "node": "Still running?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Still running?": {
      "main": [
        [
          {
            "node": "Wait 5 s",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Run finished",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 5 s": {
      "main": [
        [
          {
            "node": "Check run",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check run": {
      "main": [
        [
          {
            "node": "Still running?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run finished": {
      "main": [
        [
          {
            "node": "Get run receipt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get run receipt": {
      "main": [
        [
          {
            "node": "Get records",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get records": {
      "main": [
        [
          {
            "node": "Run log entry",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run log entry": {
      "main": [
        [
          {
            "node": "Run log (sheet)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run log (sheet)": {
      "main": [
        [
          {
            "node": "Map records to sheet rows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Map records to sheet rows": {
      "main": [
        [
          {
            "node": "Any rows?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Any rows?": {
      "main": [
        [
          {
            "node": "Funding research (sheet)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Save progress",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Funding research (sheet)": {
      "main": [
        [
          {
            "node": "Save progress",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save progress": {
      "main": [
        [
          {
            "node": "Run failed?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run failed?": {
      "main": [
        [
          {
            "node": "Stop: run failed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "timezone": "America/New_York"
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "tags": []
}