{
  "id": "1jVzJbB4Byvw7NUK",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Enrich HubSpot Companies: Firmographics, tech & AI-powered custom attributes",
  "tags": [],
  "nodes": [
    {
      "id": "81c10c26-e46e-4af2-ad49-c2007792c8d9",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -128,
        384
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-5.1",
          "cachedResultName": "gpt-5.1"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "892216a0-c898-4e58-add6-be9114a750d4",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        64,
        384
      ],
      "parameters": {
        "jsonSchemaExample": "{\n  \"website_name\": \"string\",\n  \"website_domain\": \"string\",\n  \"key_positioning_elements\": [\"string\"],\n  \"target_audience\": \"string\",\n  \"competitive_positioning_statement\": \"string\",\n  \"summary\": \"string\",\n  \"feature_1\": \"string\",\n  \"feature_2\": \"string\",\n  \"feature_3\": \"string\",\n  \"pricing_model\": \"string\",\n  \"list_of_prices\": [\"string\"],\n  \"list_of_pros\": [\"string\"],\n  \"list_of_cons\": [\"string\"],\n  \"personas_mentioned\": [\"string\"],\n  \"value_propositions\": [\"string\"],\n  \"results\": [\"string\"]\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "4cd029da-490b-4c55-a34a-a6d159b991db",
      "name": "Sona Enrich",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueRegularOutput",
      "position": [
        80,
        1040
      ],
      "parameters": {
        "url": "https://api2.sonalabs.com/resource/company/enrich",
        "options": {},
        "sendQuery": true,
        "sendHeaders": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "website",
              "value": "={{ $json.website_domain.toLowerCase() + (/\\.[a-z]{2,}$/i.test($json.website_domain.toLowerCase()) ? '' : '.com') }}"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "x-api-key"
            },
            {
              "name": "content-type",
              "value": "application/json"
            },
            {
              "name": "accept",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "eff70326-9d2f-4d54-b8e8-9c10d8cb1a5b",
      "name": "End",
      "type": "n8n-nodes-base.noOp",
      "position": [
        208,
        944
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "e6ce8d18-2541-40e1-8391-53f786f13cdc",
      "name": "Start",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -800,
        160
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "8f0ba93b-ebfe-45a8-931e-adfd8ed0c82d",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -848,
        -80
      ],
      "parameters": {
        "width": 640,
        "height": 752,
        "content": "## \ud83d\udce5 Step 1: Data Input & Web Scraping\n\n**What happens here:**\n\n- Reads company domains from Google Sheets\n- Scrapes each website's content\n- Extracts and cleans main content\n- Removes navigation, footers, and noise"
      },
      "typeVersion": 1
    },
    {
      "id": "24f14c39-7a04-4f9e-ac10-fb44f31b14a6",
      "name": "Get Company List from Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -608,
        160
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1qUir1c-_YOUR_AWS_SECRET_KEY_HERE#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1qUir1c-_ScMnoYVoQ0W41nsv5IpLW6rjK8HUNqvNnAg",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1qUir1c-_YOUR_AWS_SECRET_KEY_HERE?usp=drivesdk",
          "cachedResultName": "example"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "ac572ae7-f872-4b8a-8e45-453aa67eaaec",
      "name": "Scrape Website Content",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -416,
        160
      ],
      "parameters": {
        "url": "={{ ($json['Website Domain'].match(/^https?:\\/\\//) ? $json['Website Domain'] : 'https://' + $json['Website Domain']).toLowerCase() }}",
        "options": {
          "batching": {
            "batch": {
              "batchSize": 1,
              "batchInterval": 2000
            }
          }
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "1bdb07f6-0638-4769-b88b-5f9bd0c14023",
      "name": "Extract HTML Content",
      "type": "n8n-nodes-base.html",
      "position": [
        -720,
        416
      ],
      "parameters": {
        "options": {},
        "operation": "extractHtmlContent",
        "extractionValues": {
          "values": [
            {
              "key": "main_content",
              "cssSelector": "main, body, article, .main-content, #content, p",
              "skipSelectors": "script, img, style, nav, footer, header"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "5ef72bdd-867a-4cda-98df-e72d50f4d1ee",
      "name": "Clean & Format Text",
      "type": "n8n-nodes-base.code",
      "position": [
        -464,
        416
      ],
      "parameters": {
        "jsCode": "// Get all items from the input\nconst items = $input.all();\n\n// Get all website domains from the sheet\nconst sheetData = $('Get Company List from Sheet').all();\n\n// Process each item and match it with the corresponding website domain by index\nconst results = items.map((item, index) => {\n  const text = item.json.main_content;\n  \n  // Split into lines and filter out noise\n  const lines = text.split('\\n').filter(line => {\n    const trimmed = line.trim();\n    \n    // Skip empty lines\n    if (!trimmed) return false;\n    \n    // Skip common noise patterns\n    if (trimmed.match(/^(Sign In|Book a Demo|Continue|Start for Free|Get a|Learn More)$/i)) return false;\n    if (trimmed.includes('javascript:void')) return false;\n    if (trimmed.includes('Thank you! Your submission')) return false;\n    if (trimmed.includes('Oops! Something went wrong')) return false;\n    if (trimmed.match(/^\\[.*?\\]$/)) return false; // Remove [links]\n    if (trimmed.match(/^(\u00a9|Terms and conditions|Privacy Policy)/)) return false;\n    if (trimmed.match(/^(LinkedIn|Twitter|Facebook)$/)) return false;\n    if (trimmed.length < 10) return false; // Skip very short lines\n    \n    return true;\n  });\n  \n  // Join back and clean up excessive whitespace\n  const cleaned = lines.join('\\n').replace(/\\n{3,}/g, '\\n\\n').trim();\n  \n  return { \n    json: { \n      main_content: cleaned,\n      website_domain: sheetData[index].json['Website Domain']\n    } \n  };\n});\n\nreturn results;"
      },
      "typeVersion": 2
    },
    {
      "id": "3424801c-26e3-4e2b-811e-4b2e2a725c2e",
      "name": "Analyze with AI",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -128,
        208
      ],
      "parameters": {
        "text": "=Analyze the following scraped website content and extract structured information. Respond ONLY in valid JSON format with no preamble, no markdown backticks, and no additional text.\n\n**Content to analyze:**\n{{ $json.main_content }}\n\n**Required JSON structure:**\n```json\n{\n  \"website_name\": \"Name of the website\"\n  \"website_domain\": \"{{ $json.website_domain }}\"\n  \"key_positioning_elements\": [\"element 1\", \"element 2\", \"element 3\"],\n  \"target_audience\": \"Description of the target audience\",\n  \"competitive_positioning_statement\": \"A clear statement of how this product/service positions itself against competitors\",\n  \"summary\": \"Brief 2-3 sentence summary of what this company/product does\",\n  \"feature_1\": \"First major feature or capability\",\n  \"feature_2\": \"Second major feature or capability\",\n  \"feature_3\": \"Third major feature or capability\",\n  \"pricing_model\": \"Description of pricing model (e.g., freemium, subscription, enterprise, usage-based)\",\n  \"list_of_prices\": [\"price tier 1\", \"price tier 2\", \"price tier 3\"],\n  \"list_of_pros\": [\"pro 1\", \"pro 2\", \"pro 3\"],\n  \"list_of_cons\": [\"con 1\", \"con 2\", \"con 3\"],\n  \"personas_mentioned\": [\"persona 1\", \"persona 2\", \"persona 3\"],\n  \"value_propositions\": [\"value prop 1\", \"value prop 2\", \"value prop 3\"],\n  \"results\": [\"result/outcome 1\", \"result/outcome 2\", \"result/outcome 3\"]\n}\n```\n\n**Instructions:**\n- Extract information directly from the content provided\n- If information is not available, use \"Not mentioned\" or empty array []\n- For pros/cons, infer based on the benefits and potential limitations mentioned\n- For personas, identify job titles, roles, or departments mentioned (e.g., \"Marketing Leaders\", \"Sales Teams\", \"RevOps\")\n- For value propositions, identify the key benefits or outcomes promised\n- For results, extract any metrics, outcomes, or success stories mentioned\n- Keep responses concise and factual\n- Return ONLY the JSON object, nothing else",
        "options": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2.1
    },
    {
      "id": "717ba359-77a2-4f4d-8c55-fc51c7fc9cf4",
      "name": "Collect AI Results",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        304,
        496
      ],
      "parameters": {
        "options": {},
        "fieldsToAggregate": {
          "fieldToAggregate": [
            {
              "fieldToAggregate": "output"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "6c3343b8-98f3-4776-b67a-8cd80069a4b2",
      "name": "Create Custom HubSpot Fields",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueRegularOutput",
      "position": [
        -752,
        960
      ],
      "parameters": {
        "url": "https://api.hubapi.com/YOUR_AWS_SECRET_KEY_HERE",
        "method": "POST",
        "options": {},
        "jsonBody": "{\n  \"inputs\": [\n    {\n      \"name\": \"tech\",\n      \"label\": \"Sona: Tech\",\n      \"type\": \"string\",\n      \"fieldType\": \"textarea\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"tech_categories\",\n      \"label\": \"Sona: Tech Categories\",\n      \"type\": \"string\",\n      \"fieldType\": \"textarea\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"min_estimated_annual_revenue\",\n      \"label\": \"Sona: Min Estimated Annual Revenue\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"max_estimated_annual_revenue\",\n      \"label\": \"Sona: Max Estimated Annual Revenue\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"sub_industry\",\n      \"label\": \"Sona: Sub Industry\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"lat\",\n      \"label\": \"Sona: Latitude\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"lng\",\n      \"label\": \"Sona: Longitude\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"logo\",\n      \"label\": \"Sona: Logo\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"type\",\n      \"label\": \"Sona: Type\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"employees_range\",\n      \"label\": \"Sona: Employees Range\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"estimated_annual_revenue\",\n      \"label\": \"Sona: Estimated Annual Revenue\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"tags\",\n      \"label\": \"Sona: Tags\",\n      \"type\": \"string\",\n      \"fieldType\": \"textarea\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"ips\",\n      \"label\": \"Sona: IPs\",\n      \"type\": \"string\",\n      \"fieldType\": \"textarea\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"category\",\n      \"label\": \"Sona: Category\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"sub_category\",\n      \"label\": \"Sona: Sub Category\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"tagline\",\n      \"label\": \"Sona: Tagline\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"specialties\",\n      \"label\": \"Sona: Specialties\",\n      \"type\": \"string\",\n      \"fieldType\": \"textarea\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"ads_30days\",\n      \"label\": \"Sona: Ads 30 Days\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"ads_365days\",\n      \"label\": \"Sona: Ads 365 Days\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"ads_ytd\",\n      \"label\": \"Sona: Ads YTD\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"social_handles\",\n      \"label\": \"Sona: Social Handles\",\n      \"type\": \"string\",\n      \"fieldType\": \"textarea\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"linkedin_url\",\n      \"label\": \"Sona: LinkedIn URL\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"facebook_url\",\n      \"label\": \"Sona: Facebook URL\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"instagram_url\",\n      \"label\": \"Sona: Instagram URL\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"youtube_url\",\n      \"label\": \"Sona: YouTube URL\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"tiktok_url\",\n      \"label\": \"Sona: TikTok URL\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"pinterest_url\",\n      \"label\": \"Sona: Pinterest URL\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"github_url\",\n      \"label\": \"Sona: GitHub URL\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"discord_url\",\n      \"label\": \"Sona: Discord URL\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"telegram_url\",\n      \"label\": \"Sona: Telegram URL\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"reddit_url\",\n      \"label\": \"Sona: Reddit URL\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"snapchat_url\",\n      \"label\": \"Sona: Snapchat URL\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"medium_url\",\n      \"label\": \"Sona: Medium URL\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"twitch_url\",\n      \"label\": \"Sona: Twitch URL\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"crunchbase_url\",\n      \"label\": \"Sona: Crunchbase URL\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"g2_url\",\n      \"label\": \"Sona: G2 URL\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"founder_identifiers\",\n      \"label\": \"Sona: Founder Identifiers\",\n      \"type\": \"string\",\n      \"fieldType\": \"textarea\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"num_founders\",\n      \"label\": \"Sona: Number of Founders\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"organic_keywords\",\n      \"label\": \"Sona: Organic Keywords\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"organic_traffic\",\n      \"label\": \"Sona: Organic Traffic\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"organic_cost\",\n      \"label\": \"Sona: Organic Cost\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"adwords_keywords\",\n      \"label\": \"Sona: AdWords Keywords\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"adwords_traffic\",\n      \"label\": \"Sona: AdWords Traffic\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"adwords_cost\",\n      \"label\": \"Sona: AdWords Cost\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"github_has_organization_projects\",\n      \"label\": \"Sona: GitHub Has Organization Projects\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"github_has_repository_projects\",\n      \"label\": \"Sona: GitHub Has Repository Projects\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"github_public_repos\",\n      \"label\": \"Sona: GitHub Public Repos\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"github_public_gists\",\n      \"label\": \"Sona: GitHub Public Gists\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"github_followers\",\n      \"label\": \"Sona: GitHub Followers\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"github_following\",\n      \"label\": \"Sona: GitHub Following\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"github_is_verified\",\n      \"label\": \"Sona: GitHub Is Verified\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"linkedin_id\",\n      \"label\": \"Sona: LinkedIn ID\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"key_positioning_elements\",\n      \"label\": \"AI: Key Positioning Elements\",\n      \"type\": \"string\",\n      \"fieldType\": \"textarea\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"target_audience\",\n      \"label\": \"AI: Target Audience\",\n      \"type\": \"string\",\n      \"fieldType\": \"textarea\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"competitive_positioning_statement\",\n      \"label\": \"AI: Competitive Positioning Statement\",\n      \"type\": \"string\",\n      \"fieldType\": \"textarea\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"summary\",\n      \"label\": \"AI: Summary\",\n      \"type\": \"string\",\n      \"fieldType\": \"textarea\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"feature_1\",\n      \"label\": \"AI: Feature 1\",\n      \"type\": \"string\",\n      \"fieldType\": \"textarea\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"feature_2\",\n      \"label\": \"AI: Feature 2\",\n      \"type\": \"string\",\n      \"fieldType\": \"textarea\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"feature_3\",\n      \"label\": \"AI: Feature 3\",\n      \"type\": \"string\",\n      \"fieldType\": \"textarea\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"pricing_model\",\n      \"label\": \"AI: Pricing Model\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"list_of_prices\",\n      \"label\": \"AI: List of Prices\",\n      \"type\": \"string\",\n      \"fieldType\": \"textarea\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"list_of_pros\",\n      \"label\": \"AI: List of Pros\",\n      \"type\": \"string\",\n      \"fieldType\": \"textarea\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"list_of_cons\",\n      \"label\": \"AI: List of Cons\",\n      \"type\": \"string\",\n      \"fieldType\": \"textarea\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"personas_mentioned\",\n      \"label\": \"AI: Personas Mentioned\",\n      \"type\": \"string\",\n      \"fieldType\": \"textarea\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"value_propositions\",\n      \"label\": \"AI: Value Propositions\",\n      \"type\": \"string\",\n      \"fieldType\": \"textarea\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"results\",\n      \"label\": \"AI: Results\",\n      \"type\": \"string\",\n      \"fieldType\": \"textarea\",\n      \"groupName\": \"companyinformation\"\n    }\n  ]\n}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "hubspotAppToken"
      },
      "credentials": {
        "hubspotAppToken": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "7ccc1fc6-a20d-4130-9838-7a63d5a516aa",
      "name": "Prepare Data for Loop",
      "type": "n8n-nodes-base.set",
      "position": [
        -544,
        960
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "1c5ea36b-0283-4c38-a1c2-2329b2419fdb",
              "name": "output",
              "type": "array",
              "value": "={{ $('Collect AI Results').first().json.output }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "f2fe5930-9eea-4b4c-bfda-067e9046135d",
      "name": "Split Companies and AI Output into Items",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        -352,
        960
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "output"
      },
      "typeVersion": 1
    },
    {
      "id": "df55c5f6-7d36-418e-aa21-3ef98b0c91a4",
      "name": "Loop Through Companies",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -128,
        960
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "0747c56e-ec5f-4168-a5e8-a051441c5b29",
      "name": "Create HubSpot Company",
      "type": "n8n-nodes-base.hubspot",
      "position": [
        -96,
        1264
      ],
      "parameters": {
        "name": "={{ $json.data.name || $('Loop Through Companies').first().json.website_name }}",
        "resource": "company",
        "authentication": "appToken",
        "additionalFields": {
          "city": "={{ $json.data.city || 'ywaa' }}",
          "timezone": "={{ $json.data.timezone || 'none' }}",
          "postalCode": "={{ $json.data.postalCode || 0 }}",
          "websiteUrl": "={{ $json.data.website || $('Loop Through Companies').first().json.website_domain || 'none' }}",
          "description": "={{ $json.data.description || 'none' }}",
          "phoneNumber": "={{ $json.data.phone || 0 }}",
          "stateRegion": "={{ $json.data.state || 'none' }}",
          "yearFounded": "={{ $json.data.founded || 0 }}",
          "annualRevenue": "={{ $json.data.annualRevenue || 0 }}",
          "countryRegion": "={{ $json.data.country || 'none' }}",
          "streetAddress": "={{ $json.data.streetAddress || 'none' }}",
          "twitterHandle": "={{ $json.data.twitterUrl || 'none' }}",
          "companyDomainName": "={{ $('Loop Through Companies').item.json.website_domain || 'none' }}",
          "numberOfEmployees": "={{ $json.data.employees || 0 }}"
        }
      },
      "credentials": {
        "hubspotAppToken": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "a6b81f29-4a05-44a1-af2e-0746f6acd949",
      "name": "Format Custom Properties",
      "type": "n8n-nodes-base.code",
      "position": [
        80,
        1264
      ],
      "parameters": {
        "jsCode": "const sonaData = $('Sona Enrich').item.json.data;\nconst loopData = $('Loop Through Companies').item.json;\n\n// Format social handles nicely\nlet formattedSocialHandles = '';\nif (sonaData.socialHandles) {\n  try {\n    const socialHandlesObj = typeof sonaData.socialHandles === 'string' \n      ? JSON.parse(sonaData.socialHandles) \n      : sonaData.socialHandles;\n    \n    formattedSocialHandles = Object.entries(socialHandlesObj)\n      .filter(([key, value]) => value) // Only include non-empty values\n      .map(([key, value]) => `${key.charAt(0).toUpperCase() + key.slice(1)}: ${value}`)\n      .join('\\n');\n  } catch (e) {\n    formattedSocialHandles = sonaData.socialHandles;\n  }\n}\n\nreturn [{\n  json: {\n    properties: {\n      // Sona enrichment fields\n      tech: Array.isArray(sonaData.tech) ? sonaData.tech.join(', ') : sonaData.tech,\n      tech_categories: Array.isArray(sonaData.techCategories) ? sonaData.techCategories.join(', ') : sonaData.techCategories,\n      min_estimated_annual_revenue: sonaData.minEstimatedAnnualRevenue,\n      max_estimated_annual_revenue: sonaData.maxEstimatedAnnualRevenue,\n      sub_industry: sonaData.subIndustry,\n      lat: sonaData.lat,\n      lng: sonaData.lng,\n      logo: sonaData.logo,\n      employees_range: sonaData.employeesRange,\n      estimated_annual_revenue: sonaData.estimatedAnnualRevenue,\n      tags: Array.isArray(sonaData.tags) ? sonaData.tags.join(', ') : sonaData.tags,\n      ips: Array.isArray(sonaData.ips) ? sonaData.ips.join(', ') : sonaData.ips,\n      category: sonaData.category,\n      sub_category: sonaData.subCategory,\n      tagline: sonaData.tagline,\n      specialties: Array.isArray(sonaData.specialties) ? sonaData.specialties.join(', ') : sonaData.specialties,\n      ads_30days: sonaData.ads30days,\n      ads_365days: sonaData.ads365days,\n      ads_ytd: sonaData.adsYTD,\n      social_handles: formattedSocialHandles,\n      linkedin_url: sonaData.linkedinUrl,\n      facebook_url: sonaData.facebookUrl,\n      instagram_url: sonaData.instagramUrl,\n      youtube_url: sonaData.youtubeUrl,\n      tiktok_url: sonaData.tiktokUrl,\n      pinterest_url: sonaData.pinterestUrl,\n      github_url: sonaData.githubUrl,\n      discord_url: sonaData.discordUrl,\n      telegram_url: sonaData.telegramUrl,\n      reddit_url: sonaData.redditUrl,\n      snapchat_url: sonaData.snapchatUrl,\n      medium_url: sonaData.mediumUrl,\n      twitch_url: sonaData.twitchUrl,\n      crunchbase_url: sonaData.crunchbaseUrl,\n      g2_url: sonaData.g2Url,\n      founder_identifiers: Array.isArray(sonaData.founderIdentifiers) ? sonaData.founderIdentifiers.join(', ') : sonaData.founderIdentifiers,\n      num_founders: sonaData.numFounders,\n      organic_keywords: sonaData.organicKeywords,\n      organic_traffic: sonaData.organicTraffic,\n      organic_cost: sonaData.organicCost,\n      adwords_keywords: sonaData.adwordsKeywords,\n      adwords_traffic: sonaData.adwordsTraffic,\n      adwords_cost: sonaData.adwordsCost,\n      github_has_organization_projects: sonaData.githubHasOrganizationProjects,\n      github_has_repository_projects: sonaData.githubHasRepositoryProjects,\n      github_public_repos: sonaData.githubPublicRepos,\n      github_public_gists: sonaData.githubPublicGists,\n      github_followers: sonaData.githubFollowers,\n      github_following: sonaData.githubFollowing,\n      github_is_verified: sonaData.githubIsVerified,\n      linkedin_id: sonaData.linkedinId,\n      \n      // AI analysis fields\n      key_positioning_elements: Array.isArray(loopData.key_positioning_elements) ? loopData.key_positioning_elements.join('.\\n') : loopData.key_positioning_elements,\n      target_audience: loopData.target_audience,\n      competitive_positioning_statement: loopData.competitive_positioning_statement,\n      summary: loopData.summary,\n      feature_1: loopData.feature_1,\n      feature_2: loopData.feature_2,\n      feature_3: loopData.feature_3,\n      pricing_model: loopData.pricing_model,\n      list_of_prices: Array.isArray(loopData.list_of_prices) ? loopData.list_of_prices.join('\\n') : loopData.list_of_prices,\n      list_of_pros: Array.isArray(loopData.list_of_pros) ? loopData.list_of_pros.join('\\n') : loopData.list_of_pros,\n      list_of_cons: Array.isArray(loopData.list_of_cons) ? loopData.list_of_cons.join('\\n') : loopData.list_of_cons,\n      personas_mentioned: Array.isArray(loopData.personas_mentioned) ? loopData.personas_mentioned.join(', ') : loopData.personas_mentioned,\n      value_propositions: Array.isArray(loopData.value_propositions) ? loopData.value_propositions.join('\\n') : loopData.value_propositions,\n      results: Array.isArray(loopData.results) ? loopData.results.join('\\n') : loopData.results\n    }\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "94f7499d-445c-4542-9b50-92912e7f3433",
      "name": "Update Company with AI Data",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        256,
        1264
      ],
      "parameters": {
        "url": "=https://api.hubapi.com/crm/v3/objects/companies/{{ $('Create HubSpot Company').first().json.companyId }}",
        "method": "PATCH",
        "options": {},
        "jsonBody": "={{ $json }}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "nodeCredentialType": "hubspotAppToken"
      },
      "credentials": {
        "hubspotAppToken": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "af82b0d9-5df4-4a72-9170-c86b32ebae24",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -192,
        -80
      ],
      "parameters": {
        "color": 4,
        "width": 640,
        "height": 752,
        "content": "## \ud83e\udd16 Step 2: AI Analysis\n\n**What happens here:**\n- Sends cleaned content to OpenAI\n- Extracts structured company intelligence\n- Identifies positioning, features, personas\n- Captures pricing, pros/cons, value props\n- Aggregates all AI results"
      },
      "typeVersion": 1
    },
    {
      "id": "7b4af74d-5f84-4b0a-b536-370a7d109892",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -848,
        688
      ],
      "parameters": {
        "color": 6,
        "width": 640,
        "height": 752,
        "content": "## \u2699\ufe0f Step 3: HubSpot Preparation\n\n**What happens here:**\n- Creates custom fields in HubSpot CRM\n- Prepares AI-extracted data for import\n- Splits aggregated data into individual companies\n- Ready for batch processing"
      },
      "typeVersion": 1
    },
    {
      "id": "43ccb613-c2b8-4129-996b-8fcae1f7f708",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -192,
        688
      ],
      "parameters": {
        "color": 7,
        "width": 640,
        "height": 752,
        "content": "## \ud83d\udd04 Step 4: Enrich & Sync to HubSpot\n\n**What happens here:**\n- Loops through each company one by one\n- Enriches with Sona API (firmographics, revenue, employees)\n- Creates company record in HubSpot\n- Formats and populates all custom fields\n- Combines AI insights + Sona data in one profile\n\n**\ud83d\udca1 Get your Sona API key:** https://platform.sonalabs.com/onboardingv2"
      },
      "typeVersion": 1
    },
    {
      "id": "a6c7e5b4-4908-4244-a950-751a0c21ed59",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1632,
        -80
      ],
      "parameters": {
        "color": 5,
        "width": 752,
        "height": 1072,
        "content": "# Enrich HubSpot Companies: Firmographics, tech & AI-powered custom attributes\n\n## \u2705 Setup Requirements\n\n**Before running this workflow, you need:**\n\n1. **Google Sheets** with a column named `Website Domain`\n   - Add company websites (e.g., `example.com`)\n\n2. **OpenAI API Key**\n   - Sign up at https://platform.openai.com\n\n3. **HubSpot Account & App Token**\n   - Get an app token from HubSpot by creating a legacy app:\n     - Go to HubSpot **Settings** > **Integrations** > **Legacy Apps**\n     - Click **Create Legacy App**\n     - Select **Private** (for one account)\n     - In the scopes section, enable the following permissions:\n       - `crm.schemas.companies.write`\n       - `crm.objects.companies.write`\n       - `crm.schemas.companies.read`\n     - Click **Create**\n     - Copy the access token from the **Auth** tab\n\n4. **Sona API Key** (for company enrichment)\n   - Sign up at https://platform.sonalabs.com/\n   - Free tier available for testing\n\n**\ud83d\udccb Output:** Fully enriched company profiles in HubSpot with AI-powered insights + firmographic data"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "c80a0b01-cec1-4115-afc0-da2abf67f6ee",
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Get Company List from Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Sona Enrich": {
      "main": [
        [
          {
            "node": "Create HubSpot Company",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Analyze with AI": {
      "main": [
        [
          {
            "node": "Collect AI Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Analyze with AI",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Collect AI Results": {
      "main": [
        [
          {
            "node": "Create Custom HubSpot Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Clean & Format Text": {
      "main": [
        [
          {
            "node": "Analyze with AI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract HTML Content": {
      "main": [
        [
          {
            "node": "Clean & Format Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Data for Loop": {
      "main": [
        [
          {
            "node": "Split Companies and AI Output into Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create HubSpot Company": {
      "main": [
        [
          {
            "node": "Format Custom Properties",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Through Companies": {
      "main": [
        [
          {
            "node": "End",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Sona Enrich",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Scrape Website Content": {
      "main": [
        [
          {
            "node": "Extract HTML Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Custom Properties": {
      "main": [
        [
          {
            "node": "Update Company with AI Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Analyze with AI",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Get Company List from Sheet": {
      "main": [
        [
          {
            "node": "Scrape Website Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Company with AI Data": {
      "main": [
        [
          {
            "node": "Loop Through Companies",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Custom HubSpot Fields": {
      "main": [
        [
          {
            "node": "Prepare Data for Loop",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Companies and AI Output into Items": {
      "main": [
        [
          {
            "node": "Loop Through Companies",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}