{
  "name": "Dark Funnel Illuminator — B: Score & Notify",
  "nodes": [
    {
      "id": "c51b3557-811f-434a-af29-27c4e7c730cc",
      "name": "Research Submitted",
      "type": "n8n-nodes-base.formTrigger",
      "typeVersion": 2.6,
      "position": [0, 96],
      "parameters": {
        "formTitle": "Dark Funnel Research Result",
        "formDescription": "After running Claygent research on a target account in Clay (funding, hiring, review-site mentions), submit the findings here to score it.",
        "formFields": {
          "values": [
            { "fieldLabel": "Account Name", "requiredField": true },
            { "fieldLabel": "Domain", "requiredField": true },
            { "fieldLabel": "Funding Signal" },
            { "fieldLabel": "Hiring Signal" },
            { "fieldLabel": "Review Mentions Signal" }
          ]
        },
        "options": { "path": "dark-funnel-research" }
      }
    },
    {
      "id": "88dd2857-60e2-40d0-a149-67c36e9bef29",
      "name": "Normalize Form Submission",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.5,
      "position": [224, 96],
      "parameters": {
        "mode": "manual",
        "includeOtherFields": false,
        "assignments": {
          "assignments": [
            { "id": "a1", "name": "accountName", "type": "string", "value": "={{ $json['Account Name'] }}" },
            { "id": "a2", "name": "domain", "type": "string", "value": "={{ $json['Domain'] }}" },
            { "id": "a3", "name": "funding", "type": "string", "value": "={{ $json['Funding Signal'] || '' }}" },
            { "id": "a4", "name": "hiring", "type": "string", "value": "={{ $json['Hiring Signal'] || '' }}" },
            { "id": "a5", "name": "reviewMentions", "type": "string", "value": "={{ $json['Review Mentions Signal'] || '' }}" }
          ]
        }
      }
    },
    {
      "id": "ee6d372b-1c09-4d59-8807-42d68c528e4e",
      "name": "Check HubSpot Domain",
      "type": "n8n-nodes-base.hubspot",
      "typeVersion": 2.2,
      "position": [448, 96],
      "alwaysOutputData": true,
      "parameters": {
        "authentication": "appToken",
        "resource": "company",
        "operation": "searchByDomain",
        "domain": "={{ $json.domain }}",
        "limit": 1,
        "returnAll": false,
        "options": {}
      },
      "credentials": { "hubspotAppToken": { "id": "ynUSCUtMOnX1f4Jl", "name": "HubSpot Service Key account" } }
    },
    {
      "id": "0306319c-8672-41f5-b43d-22844d9ec11e",
      "name": "Merge HubSpot Result",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.5,
      "position": [672, 96],
      "parameters": {
        "mode": "manual",
        "includeOtherFields": false,
        "assignments": {
          "assignments": [
            { "id": "b1", "name": "accountName", "type": "string", "value": "={{ $('Normalize Form Submission').item.json.accountName }}" },
            { "id": "b2", "name": "domain", "type": "string", "value": "={{ $('Normalize Form Submission').item.json.domain }}" },
            { "id": "b3", "name": "funding", "type": "string", "value": "={{ $('Normalize Form Submission').item.json.funding }}" },
            { "id": "b4", "name": "hiring", "type": "string", "value": "={{ $('Normalize Form Submission').item.json.hiring }}" },
            { "id": "b5", "name": "reviewMentions", "type": "string", "value": "={{ $('Normalize Form Submission').item.json.reviewMentions }}" },
            { "id": "b6", "name": "hubspotMatch", "type": "boolean", "value": "={{ $json.id ? true : false }}" }
          ]
        }
      }
    },
    {
      "id": "bc627ade-261b-43c5-9643-4347eb8cbc55",
      "name": "Check Salesforce Open Opportunity",
      "type": "n8n-nodes-base.salesforce",
      "typeVersion": 1.1,
      "position": [896, 96],
      "alwaysOutputData": true,
      "parameters": {
        "resource": "search",
        "operation": "query",
        "query": "={{ \"SELECT Id, (SELECT Id FROM Opportunities WHERE IsClosed = false) FROM Account WHERE Website LIKE '%\" + $json.domain + \"%' LIMIT 1\" }}"
      },
      "credentials": { "salesforceOAuth2Api": { "id": "553Tae1kPe5Wpthq", "name": "Salesforce account" } }
    },
    {
      "id": "1e60fe2b-b3fe-4938-94b0-529318322875",
      "name": "Merge Salesforce Result",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.5,
      "position": [1120, 96],
      "parameters": {
        "mode": "manual",
        "includeOtherFields": false,
        "assignments": {
          "assignments": [
            { "id": "c1", "name": "accountName", "type": "string", "value": "={{ $('Merge HubSpot Result').item.json.accountName }}" },
            { "id": "c2", "name": "domain", "type": "string", "value": "={{ $('Merge HubSpot Result').item.json.domain }}" },
            { "id": "c3", "name": "funding", "type": "string", "value": "={{ $('Merge HubSpot Result').item.json.funding }}" },
            { "id": "c4", "name": "hiring", "type": "string", "value": "={{ $('Merge HubSpot Result').item.json.hiring }}" },
            { "id": "c5", "name": "reviewMentions", "type": "string", "value": "={{ $('Merge HubSpot Result').item.json.reviewMentions }}" },
            { "id": "c6", "name": "hubspotMatch", "type": "boolean", "value": "={{ $('Merge HubSpot Result').item.json.hubspotMatch }}" },
            { "id": "c7", "name": "salesforceMatch", "type": "boolean", "value": "={{ ($json.Opportunities && $json.Opportunities.records && $json.Opportunities.records.length > 0) ? true : false }}" }
          ]
        }
      }
    },
    {
      "id": "0ecbbf2b-da2f-48b8-939a-fd9e8c33b3f6",
      "name": "Genuinely Pre-Funnel?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [1344, 96],
      "parameters": {
        "conditions": {
          "combinator": "and",
          "conditions": [
            { "leftValue": "={{ $json.hubspotMatch }}", "operator": { "operation": "false", "type": "boolean" }, "rightValue": false },
            { "leftValue": "={{ $json.salesforceMatch }}", "operator": { "operation": "false", "type": "boolean" }, "rightValue": false }
          ],
          "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict" }
        },
        "options": {}
      }
    },
    {
      "id": "653bec7b-1871-4565-a7e7-1be708384707",
      "name": "Prepare Disqualified Row",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.5,
      "position": [1632, 192],
      "parameters": {
        "mode": "manual",
        "includeOtherFields": true,
        "assignments": {
          "assignments": [
            { "id": "d1", "name": "status", "type": "string", "value": "disqualified" },
            { "id": "d2", "name": "reasoning", "type": "string", "value": "Already has a HubSpot contact or an open Salesforce opportunity - not genuinely pre-funnel." },
            { "id": "d3", "name": "keySignals", "type": "string", "value": "={{ $json.funding }} | {{ $json.hiring }} | {{ $json.reviewMentions }}" },
            { "id": "d4", "name": "slackNotified", "type": "boolean", "value": false },
            { "id": "d5", "name": "checkedAt", "type": "string", "value": "={{ $now.toISO() }}" }
          ]
        }
      }
    },
    {
      "id": "84e2a535-d7ac-4a69-a409-e10a4c54d956",
      "name": "Log Disqualified Account",
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [1920, 192],
      "parameters": {
        "resource": "row",
        "operation": "insert",
        "dataTableId": { "__rl": true, "mode": "id", "value": "Cm1FcGSM7nIYcikY", "cachedResultName": "Dark Funnel Nominations" },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "accountName": "={{ $json.accountName }}",
            "domain": "={{ $json.domain }}",
            "reasoning": "={{ $json.reasoning }}",
            "keySignals": "={{ $json.keySignals }}",
            "hubspotMatch": "={{ $json.hubspotMatch }}",
            "salesforceMatch": "={{ $json.salesforceMatch }}",
            "status": "={{ $json.status }}",
            "slackNotified": "={{ $json.slackNotified }}",
            "checkedAt": "={{ $json.checkedAt }}"
          },
          "schema": [
            { "id": "accountName", "displayName": "accountName", "type": "string", "display": true, "canBeUsedToMatch": true },
            { "id": "domain", "displayName": "domain", "type": "string", "display": true, "canBeUsedToMatch": true },
            { "id": "reasoning", "displayName": "reasoning", "type": "string", "display": true, "canBeUsedToMatch": true },
            { "id": "keySignals", "displayName": "keySignals", "type": "string", "display": true, "canBeUsedToMatch": true },
            { "id": "hubspotMatch", "displayName": "hubspotMatch", "type": "boolean", "display": true, "canBeUsedToMatch": true },
            { "id": "salesforceMatch", "displayName": "salesforceMatch", "type": "boolean", "display": true, "canBeUsedToMatch": true },
            { "id": "status", "displayName": "status", "type": "string", "display": true, "canBeUsedToMatch": true },
            { "id": "slackNotified", "displayName": "slackNotified", "type": "boolean", "display": true, "canBeUsedToMatch": true },
            { "id": "checkedAt", "displayName": "checkedAt", "type": "date", "display": true, "canBeUsedToMatch": true }
          ]
        },
        "options": {}
      }
    },
    {
      "id": "683ea7de-c7f1-45bb-a3b2-08c72fc021d7",
      "name": "Score In-Market Likelihood",
      "type": "@n8n/n8n-nodes-langchain.anthropic",
      "typeVersion": 1,
      "position": [1568, 0],
      "parameters": {
        "resource": "text",
        "operation": "message",
        "modelId": { "__rl": true, "mode": "id", "value": "claude-sonnet-4-5-20250929" },
        "messages": {
          "values": [
            {
              "role": "user",
              "content": "=You are scoring an anonymous, pre-funnel target account for Fortavault, a data security / compliance vendor. Fortavault's ICP skews toward mid-market and enterprise companies in regulated, data-heavy industries (financial services, healthcare, and SaaS handling sensitive customer data) - companies who need to prove compliance posture, not just companies who might buy security software generically. (This is a working ICP description for Day 6; Day 16's ICP & TAM Definition Engine will replace it with one derived from actual Salesforce win/loss data.)\n\nAccount: {{ $json.accountName }} ({{ $json.domain }})\nResearch signals from Clay/Claygent:\n- Funding: {{ $json.funding }}\n- Hiring: {{ $json.hiring }}\n- Review-site mentions: {{ $json.reviewMentions }}\n\nScore this account's in-market likelihood from 0-100. Ground the score in the specific signals above, not generic optimism - an account with no real signals should score low even if it superficially fits the ICP. Return ONLY valid JSON, no other text, using this exact shape: {\"score\": 0-100 integer, \"reasoning\": \"2-3 sentences citing the specific signal(s) driving the score\", \"keySignals\": \"one-line summary\"}"
            }
          ]
        },
        "options": { "maxTokens": 500, "temperature": 0.3 }
      },
      "credentials": { "anthropicApi": { "id": "3d3ZiTi7BwnkFwqU", "name": "Anthropic account" } }
    },
    {
      "id": "0b53a591-7b2a-4d2c-bfb1-15d6a2c97dc8",
      "name": "Parse Claude Score",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [1920, 0],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "const item = $input.item.json;\nlet raw = item.content;\nif (Array.isArray(raw)) {\n  raw = raw.map((b) => (b && b.text) ? b.text : '').join('');\n} else if (typeof raw !== 'string') {\n  raw = item.text || item.output || JSON.stringify(item);\n}\nlet parsed = { score: null, reasoning: 'Could not parse Claude response: ' + String(raw).slice(0, 200), keySignals: '' };\ntry {\n  const match = raw.match(/\\{[\\s\\S]*\\}/);\n  parsed = JSON.parse(match ? match[0] : raw);\n} catch (e) {\n  parsed.reasoning = 'Parse error: ' + e.message;\n}\nconst prior = $('Merge Salesforce Result').item.json;\nreturn { json: {\n  accountName: prior.accountName,\n  domain: prior.domain,\n  hubspotMatch: prior.hubspotMatch,\n  salesforceMatch: prior.salesforceMatch,\n  score: parsed.score,\n  reasoning: parsed.reasoning,\n  keySignals: parsed.keySignals\n} };"
      }
    },
    {
      "id": "ab220d07-7e41-4c60-8daa-d2cf2f9cac92",
      "name": "Prepare Scored Row",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.5,
      "position": [2144, 0],
      "parameters": {
        "mode": "manual",
        "includeOtherFields": true,
        "assignments": {
          "assignments": [
            { "id": "e1", "name": "status", "type": "string", "value": "={{ $json.score >= 70 ? \"scored-high\" : \"scored-low\" }}" },
            { "id": "e2", "name": "slackNotified", "type": "boolean", "value": "={{ $json.score >= 70 }}" },
            { "id": "e3", "name": "checkedAt", "type": "string", "value": "={{ $now.toISO() }}" }
          ]
        }
      }
    },
    {
      "id": "0dd03ff0-0aa7-4be2-8735-1c8373995627",
      "name": "Log Scored Account",
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [2368, 0],
      "parameters": {
        "resource": "row",
        "operation": "insert",
        "dataTableId": { "__rl": true, "mode": "id", "value": "Cm1FcGSM7nIYcikY", "cachedResultName": "Dark Funnel Nominations" },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "accountName": "={{ $json.accountName }}",
            "domain": "={{ $json.domain }}",
            "score": "={{ $json.score }}",
            "reasoning": "={{ $json.reasoning }}",
            "keySignals": "={{ $json.keySignals }}",
            "hubspotMatch": "={{ $json.hubspotMatch }}",
            "salesforceMatch": "={{ $json.salesforceMatch }}",
            "status": "={{ $json.status }}",
            "slackNotified": "={{ $json.slackNotified }}",
            "checkedAt": "={{ $json.checkedAt }}"
          },
          "schema": [
            { "id": "accountName", "displayName": "accountName", "type": "string", "display": true, "canBeUsedToMatch": true },
            { "id": "domain", "displayName": "domain", "type": "string", "display": true, "canBeUsedToMatch": true },
            { "id": "score", "displayName": "score", "type": "number", "display": true, "canBeUsedToMatch": true },
            { "id": "reasoning", "displayName": "reasoning", "type": "string", "display": true, "canBeUsedToMatch": true },
            { "id": "keySignals", "displayName": "keySignals", "type": "string", "display": true, "canBeUsedToMatch": true },
            { "id": "hubspotMatch", "displayName": "hubspotMatch", "type": "boolean", "display": true, "canBeUsedToMatch": true },
            { "id": "salesforceMatch", "displayName": "salesforceMatch", "type": "boolean", "display": true, "canBeUsedToMatch": true },
            { "id": "status", "displayName": "status", "type": "string", "display": true, "canBeUsedToMatch": true },
            { "id": "slackNotified", "displayName": "slackNotified", "type": "boolean", "display": true, "canBeUsedToMatch": true },
            { "id": "checkedAt", "displayName": "checkedAt", "type": "date", "display": true, "canBeUsedToMatch": true }
          ]
        },
        "options": {}
      }
    },
    {
      "id": "18d6632a-132c-41ad-a423-b4600439c451",
      "name": "High Score?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [2592, 0],
      "parameters": {
        "conditions": {
          "combinator": "and",
          "conditions": [
            { "leftValue": "={{ $('Prepare Scored Row').item.json.score }}", "operator": { "type": "number", "operation": "gte" }, "rightValue": 70 }
          ],
          "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict" }
        },
        "options": {}
      }
    },
    {
      "id": "3fb7e7ae-2c2b-4a58-b4ec-b63340af23b4",
      "name": "Post Nomination to Slack",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.7,
      "position": [2816, 0],
      "parameters": {
        "resource": "message",
        "operation": "post",
        "select": "channel",
        "channelId": { "__rl": true, "mode": "id", "value": "C0BQ3G96HL6", "cachedResultName": "gtm-sprint" },
        "messageType": "text",
        "text": "=Dark Funnel nomination - {{ $('Prepare Scored Row').item.json.accountName }} ({{ $('Prepare Scored Row').item.json.domain }})\nScore: {{ $('Prepare Scored Row').item.json.score }}/100\nWhy: {{ $('Prepare Scored Row').item.json.reasoning }}\nSignals: {{ $('Prepare Scored Row').item.json.keySignals }}\nStatus: no HubSpot contact, no open Salesforce opportunity - genuinely pre-funnel.",
        "otherOptions": {}
      },
      "credentials": { "slackApi": { "id": "mv7TIi8kucFPqPg6", "name": "Slack account" } }
    }
  ],
  "connections": {
    "Research Submitted": { "main": [[{ "node": "Normalize Form Submission", "type": "main", "index": 0 }]] },
    "Normalize Form Submission": { "main": [[{ "node": "Check HubSpot Domain", "type": "main", "index": 0 }]] },
    "Check HubSpot Domain": { "main": [[{ "node": "Merge HubSpot Result", "type": "main", "index": 0 }]] },
    "Merge HubSpot Result": { "main": [[{ "node": "Check Salesforce Open Opportunity", "type": "main", "index": 0 }]] },
    "Check Salesforce Open Opportunity": { "main": [[{ "node": "Merge Salesforce Result", "type": "main", "index": 0 }]] },
    "Merge Salesforce Result": { "main": [[{ "node": "Genuinely Pre-Funnel?", "type": "main", "index": 0 }]] },
    "Genuinely Pre-Funnel?": {
      "main": [
        [{ "node": "Score In-Market Likelihood", "type": "main", "index": 0 }],
        [{ "node": "Prepare Disqualified Row", "type": "main", "index": 0 }]
      ]
    },
    "Score In-Market Likelihood": { "main": [[{ "node": "Parse Claude Score", "type": "main", "index": 0 }]] },
    "Parse Claude Score": { "main": [[{ "node": "Prepare Scored Row", "type": "main", "index": 0 }]] },
    "Prepare Scored Row": { "main": [[{ "node": "Log Scored Account", "type": "main", "index": 0 }]] },
    "Log Scored Account": { "main": [[{ "node": "High Score?", "type": "main", "index": 0 }]] },
    "High Score?": { "main": [[{ "node": "Post Nomination to Slack", "type": "main", "index": 0 }]] },
    "Prepare Disqualified Row": { "main": [[{ "node": "Log Disqualified Account", "type": "main", "index": 0 }]] }
  }
}
