{
  "name": "Bella Plugin \u2014 Apollo School Enricher",
  "nodes": [
    {
      "id": "08d4be81-5950-466d-a7b8-088939b9f3cd",
      "name": "Execute Workflow Trigger",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ],
      "parameters": {}
    },
    {
      "id": "e81aac5f-7264-4528-94e0-9799687e4ff1",
      "name": "Note: Apollo API Key",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        280,
        -120
      ],
      "parameters": {
        "content": "\u26a0\ufe0f Add Apollo API key to the body or Authorization header in the HTTP Request node below.",
        "height": 80,
        "width": 360,
        "color": 4
      }
    },
    {
      "id": "01e38e72-e79b-48a9-a8a2-e064fb7a518c",
      "name": "HTTP Request: Apollo People Search",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [
        280,
        0
      ],
      "parameters": {
        "method": "POST",
        "url": "https://api.apollo.io/v1/people/search",
        "sendBody": true,
        "contentType": "json",
        "body": {
          "q_organization_name": "={{ $json.school_name }}",
          "person_titles": [
            "Director",
            "Administrator",
            "Owner",
            "Principal"
          ],
          "organization_locations": [
            "={{ $json.state || 'California' }}"
          ],
          "api_key": "APOLLO_KEY_PLACEHOLDER"
        }
      }
    },
    {
      "id": "57bcbb47-f61e-4764-8a32-b053e058b466",
      "name": "Code: Extract Best Contact",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        560,
        0
      ],
      "parameters": {
        "jsCode": "const data = $input.first().json;\nconst people = data.people || [];\nconst best = people.find(p => p.email) || people[0] || {};\nreturn [{ json: {\n  found: !!best.id,\n  contact_name: (best.first_name || '') + ' ' + (best.last_name || ''),\n  contact_email: best.email || '',\n  contact_title: best.title || '',\n  contact_linkedin: best.linkedin_url || '',\n  phone: best.sanitized_phone || '',\n  organization: best.organization_name || '',\n  all_contacts_count: people.length,\n} }];"
      }
    },
    {
      "id": "182c27d5-b553-472a-a69b-8f141ea1b556",
      "name": "Set: Output",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3,
      "position": [
        840,
        0
      ],
      "parameters": {
        "mode": "passthrough"
      }
    }
  ],
  "connections": {
    "Execute Workflow Trigger": {
      "main": [
        [
          {
            "node": "HTTP Request: Apollo People Search",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request: Apollo People Search": {
      "main": [
        [
          {
            "node": "Code: Extract Best Contact",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code: Extract Best Contact": {
      "main": [
        [
          {
            "node": "Set: Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  }
}