{
  "name": "Technographic Enrichment — HubSpot + BuiltWith",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 22,
              "field": "weeks",
              "triggerAtDay": 0
            }
          ]
        }
      },
      "id": "schedule-trigger",
      "name": "Weekly Schedule",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [0, 0]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.hubapi.com/crm/v3/objects/companies/search",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "hubspotApi",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"filterGroups\": [{\n    \"filters\": [{\n      \"propertyName\": \"tech_stack_crm\",\n      \"operator\": \"NOT_HAS_PROPERTY\"\n    }]\n  }],\n  \"properties\": [\"domain\", \"name\", \"tech_stack_crm\"],\n  \"limit\": 50\n}",
        "options": {}
      },
      "id": "search-companies",
      "name": "Search Companies",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [220, 0],
      "credentials": {
        "hubspotApi": {
          "id": "credential-id",
          "name": "HubSpot API"
        }
      }
    },
    {
      "parameters": {
        "batchSize": 1,
        "options": {}
      },
      "id": "loop-companies",
      "name": "Loop Companies",
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [440, 0]
    },
    {
      "parameters": {
        "method": "GET",
        "url": "https://api.builtwith.com/v21/api.json",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "KEY",
              "value": "={{ $credentials.builtWithApi.apiKey }}"
            },
            {
              "name": "LOOKUP",
              "value": "={{ $json.properties.domain }}"
            }
          ]
        },
        "options": {}
      },
      "id": "builtwith-lookup",
      "name": "BuiltWith Lookup",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [660, 0]
    },
    {
      "parameters": {
        "jsCode": "const response = $input.first().json;\nconst technologies = response?.Results?.[0]?.Result?.Paths?.[0]?.Technologies || [];\n\nconst categories = {\n  crm: [],\n  marketing: [],\n  analytics: [],\n  ecommerce: [],\n  hosting: [],\n};\n\nconst categoryMap = {\n  \"crm\": \"crm\",\n  \"marketing-automation\": \"marketing\",\n  \"email\": \"marketing\",\n  \"analytics\": \"analytics\",\n  \"web-analytics\": \"analytics\",\n  \"ecommerce\": \"ecommerce\",\n  \"shopping-cart\": \"ecommerce\",\n  \"hosting\": \"hosting\",\n  \"cdn\": \"hosting\",\n};\n\nfor (const tech of technologies) {\n  const tag = tech.Tag?.toLowerCase() || \"\";\n  for (const [pattern, category] of Object.entries(categoryMap)) {\n    if (tag.includes(pattern) || (tech.Categories || []).some(c => c.toLowerCase().includes(pattern))) {\n      categories[category].push(tech.Name);\n      break;\n    }\n  }\n}\n\nreturn [{\n  json: {\n    tech_stack_crm: categories.crm.join(\", \") || \"None detected\",\n    tech_stack_marketing: categories.marketing.join(\", \") || \"None detected\",\n    tech_stack_analytics: categories.analytics.join(\", \") || \"None detected\",\n    tech_stack_all: technologies.map(t => t.Name).join(\", \"),\n    tech_count: technologies.length,\n  }\n}];"
      },
      "id": "parse-tech-stack",
      "name": "Parse Tech Stack",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [880, 0]
    },
    {
      "parameters": {
        "method": "PATCH",
        "url": "=https://api.hubapi.com/crm/v3/objects/companies/{{ $('Loop Companies').item.json.id }}",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "hubspotApi",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"properties\": {\n    \"tech_stack_crm\": \"{{ $json.tech_stack_crm }}\",\n    \"tech_stack_marketing\": \"{{ $json.tech_stack_marketing }}\",\n    \"tech_stack_analytics\": \"{{ $json.tech_stack_analytics }}\",\n    \"tech_stack_all\": \"{{ $json.tech_stack_all }}\",\n    \"tech_enrichment_date\": \"{{ new Date().toISOString().split('T')[0] }}\"\n  }\n}",
        "options": {}
      },
      "id": "update-company",
      "name": "Update Company",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [1100, 0],
      "credentials": {
        "hubspotApi": {
          "id": "credential-id",
          "name": "HubSpot API"
        }
      }
    },
    {
      "parameters": {
        "amount": 2,
        "unit": "seconds"
      },
      "id": "wait-rate-limit",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [1320, 0]
    }
  ],
  "connections": {
    "Weekly Schedule": {
      "main": [[{ "node": "Search Companies", "type": "main", "index": 0 }]]
    },
    "Search Companies": {
      "main": [[{ "node": "Loop Companies", "type": "main", "index": 0 }]]
    },
    "Loop Companies": {
      "main": [
        [{ "node": "BuiltWith Lookup", "type": "main", "index": 0 }],
        []
      ]
    },
    "BuiltWith Lookup": {
      "main": [[{ "node": "Parse Tech Stack", "type": "main", "index": 0 }]]
    },
    "Parse Tech Stack": {
      "main": [[{ "node": "Update Company", "type": "main", "index": 0 }]]
    },
    "Update Company": {
      "main": [[{ "node": "Wait", "type": "main", "index": 0 }]]
    },
    "Wait": {
      "main": [[{ "node": "Loop Companies", "type": "main", "index": 0 }]]
    }
  },
  "pinData": {},
  "settings": { "executionOrder": "v1" },
  "staticData": null,
  "tags": [],
  "triggerCount": 0,
  "active": false,
  "meta": { "instanceId": "", "templateId": "revi-tech-enrich" }
}
