{
  "name": "Bella - Full Pipeline (Orchestrator)",
  "nodes": [
    {
      "id": "32dd49f6-186f-4c9c-8595-bdf85d56f5c3",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        0
      ],
      "parameters": {
        "httpMethod": "POST",
        "path": "bella-pipeline",
        "responseMode": "responseNode"
      }
    },
    {
      "id": "b3367784-6b44-4766-b8d5-968e4d496dfc",
      "name": "Note: Master Pipeline",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        -140
      ],
      "parameters": {
        "content": "BELLA MASTER PIPELINE\nRun for each lead from Google Sheet.\nConnect Google Sheets trigger to automate bulk processing.\nSub-workflow IDs must be set after all workflows are created.",
        "height": 120,
        "width": 400,
        "color": 4
      }
    },
    {
      "id": "fc80780b-a338-42f3-96c3-8904088130eb",
      "name": "Execute Workflow: Apollo Enricher",
      "type": "n8n-nodes-base.executeWorkflow",
      "typeVersion": 1,
      "position": [
        280,
        0
      ],
      "parameters": {
        "source": "database",
        "workflowId": "APOLLO_ENRICHER_WORKFLOW_ID",
        "workflowInputs": {
          "schema": [
            {
              "key": "school_name",
              "type": "string"
            },
            {
              "key": "state",
              "type": "string"
            }
          ],
          "value": {
            "school_name": "={{ $json.school_name || $json.body.school_name }}",
            "state": "={{ $json.state || $json.body.state || 'California' }}"
          }
        }
      }
    },
    {
      "id": "77f79bf4-acda-4793-9296-01100ba3fc84",
      "name": "Execute Workflow: BPPE Lookup",
      "type": "n8n-nodes-base.executeWorkflow",
      "typeVersion": 1,
      "position": [
        280,
        200
      ],
      "parameters": {
        "source": "database",
        "workflowId": "BPPE_LOOKUP_WORKFLOW_ID",
        "workflowInputs": {
          "schema": [
            {
              "key": "school_name",
              "type": "string"
            }
          ],
          "value": {
            "school_name": "={{ $json.school_name || $json.body.school_name }}"
          }
        }
      }
    },
    {
      "id": "6017889d-370c-4c6f-a4c0-ab32296aa5d2",
      "name": "Merge: Combine Data",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3,
      "position": [
        560,
        0
      ],
      "parameters": {
        "mode": "combine",
        "combinationMode": "multiplex"
      }
    },
    {
      "id": "0723a134-5b18-4f96-81ce-c1aef5d561f6",
      "name": "AI: Categorize Lead",
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "typeVersion": 1,
      "position": [
        840,
        0
      ],
      "parameters": {
        "model": "claude-sonnet-4-6",
        "messages": {
          "values": [
            {
              "role": "user",
              "content": "You are Bella's outbound sales AI. Given this enriched school data, return ONLY valid JSON (no markdown) with keys: use_case, cta_variant, personalized_hook, email_subject, email_preview.\n\nData: {{ JSON.stringify($json) }}"
            }
          ]
        }
      }
    },
    {
      "id": "c033a96a-b35e-49ae-a0d6-d703b54cbcd6",
      "name": "Execute Workflow: Generate Landing Page",
      "type": "n8n-nodes-base.executeWorkflow",
      "typeVersion": 1,
      "position": [
        1120,
        0
      ],
      "parameters": {
        "source": "database",
        "workflowId": "LANDING_PAGE_WORKFLOW_ID",
        "workflowInputs": {
          "schema": [
            {
              "key": "school_name",
              "type": "string"
            },
            {
              "key": "contact_name",
              "type": "string"
            },
            {
              "key": "contact_email",
              "type": "string"
            },
            {
              "key": "personalized_hook",
              "type": "string"
            },
            {
              "key": "cta_variant",
              "type": "string"
            }
          ],
          "value": {
            "school_name": "={{ $json.school_name }}",
            "contact_name": "={{ $json.contact_name }}",
            "contact_email": "={{ $json.contact_email }}",
            "personalized_hook": "={{ $json.personalized_hook }}",
            "cta_variant": "={{ $json.cta_variant }}"
          }
        }
      }
    },
    {
      "id": "5ea1997f-1b65-4245-978c-81bd513cef75",
      "name": "Code: Build Final Result",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1400,
        0
      ],
      "parameters": {
        "jsCode": "const current = $input.first().json;\nreturn [{ json: {\n  school_name: current.school_name,\n  contact_name: current.contact_name,\n  contact_email: current.contact_email,\n  contact_title: current.contact_title,\n  use_case: current.use_case,\n  cta_variant: current.cta_variant,\n  personalized_hook: current.personalized_hook,\n  email_subject: current.email_subject,\n  email_preview: current.email_preview,\n  bppe_citation: current.citation_number || null,\n  landing_page_url: current.page_url || null,\n  pipeline_completed_at: new Date().toISOString(),\n} }];"
      }
    },
    {
      "id": "f378f703-ef5b-452b-889f-4e4291415957",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        1680,
        0
      ],
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ { success: true, lead: $json } }}"
      }
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Execute Workflow: Apollo Enricher",
            "type": "main",
            "index": 0
          },
          {
            "node": "Execute Workflow: BPPE Lookup",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Execute Workflow: Apollo Enricher": {
      "main": [
        [
          {
            "node": "Merge: Combine Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Execute Workflow: BPPE Lookup": {
      "main": [
        [
          {
            "node": "Merge: Combine Data",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Merge: Combine Data": {
      "main": [
        [
          {
            "node": "AI: Categorize Lead",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI: Categorize Lead": {
      "main": [
        [
          {
            "node": "Execute Workflow: Generate Landing Page",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Execute Workflow: Generate Landing Page": {
      "main": [
        [
          {
            "node": "Code: Build Final Result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code: Build Final Result": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  }
}