{
  "name": "Aviara Labs - AI Lead Automation System",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "incoming-lead",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "65bb63e0-c9c3-4be0-86bc-6335bc57ab54",
      "name": "Webhook Trigger",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        512,
        464
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": false,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 1
          },
          "conditions": [
            {
              "id": "check-name",
              "leftValue": "={{ $json.query.name || $json.body.name }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty"
              }
            },
            {
              "id": "check-email",
              "leftValue": "={{ $json.query.email || $json.body.email }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty"
              }
            },
            {
              "id": "check-company",
              "leftValue": "={{ $json.query.company || $json.body.company }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty"
              }
            },
            {
              "id": "check-email-format",
              "leftValue": "={{ $json.query.email || $json.body.email }}",
              "rightValue": "@",
              "operator": {
                "type": "string",
                "operation": "contains"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "64e7f69a-25d3-42e7-8eb8-90bad09cdb45",
      "name": "Validate Input Data",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        736,
        464
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify({ \"status\": \"error\", \"message\": \"name, email, and company must be provided.\", \"code\": 400 }) }}",
        "options": {
          "responseCode": 400
        }
      },
      "id": "bca676fa-5077-4a9f-99d9-ffd0ba3d5522",
      "name": "Validation Failed Response",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        960,
        560
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://backend-woad-three-14.vercel.app/api/v1/enrich",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "name",
              "value": "={{ $(\"Webhook Trigger\").item.json.query.name || $(\"Webhook Trigger\").item.json.body.name }}"
            },
            {
              "name": "email",
              "value": "={{ $(\"Webhook Trigger\").item.json.query.email || $(\"Webhook Trigger\").item.json.body.email }}"
            },
            {
              "name": "company",
              "value": "={{ $(\"Webhook Trigger\").item.json.query.company || $(\"Webhook Trigger\").item.json.body.company }}"
            }
          ]
        },
        "options": {
          "timeout": 10000
        }
      },
      "id": "fe2915c3-157e-439b-aff2-8187a7fa1327",
      "name": "Call Enrichment API",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        960,
        368
      ],
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://backend-woad-three-14.vercel.app/api/v1/classify",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "message",
              "value": "={{ $(\"Webhook Trigger\").item.json.query.name || $(\"Webhook Trigger\").item.json.body.name }} from {{ $(\"Webhook Trigger\").item.json.query.company || $(\"Webhook Trigger\").item.json.body.company }} is interested in our services."
            }
          ]
        },
        "options": {
          "timeout": 10000
        }
      },
      "id": "2471a05e-9b45-4356-98d6-30e62c5257a5",
      "name": "Call Intent Classification API",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1184,
        368
      ],
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://backend-woad-three-14.vercel.app/api/v1/leads",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "name",
              "value": "={{ $(\"Webhook Trigger\").item.json.query.name || $(\"Webhook Trigger\").item.json.body.name }}"
            },
            {
              "name": "email",
              "value": "={{ $(\"Webhook Trigger\").item.json.query.email || $(\"Webhook Trigger\").item.json.body.email }}"
            },
            {
              "name": "company",
              "value": "={{ $(\"Webhook Trigger\").item.json.query.company || $(\"Webhook Trigger\").item.json.body.company }}"
            },
            {
              "name": "message",
              "value": "={{ $(\"Webhook Trigger\").item.json.query.name || $(\"Webhook Trigger\").item.json.body.name }} from {{ $(\"Webhook Trigger\").item.json.query.company || $(\"Webhook Trigger\").item.json.body.company }} is interested in our services."
            },
            {
              "name": "linkedin_url",
              "value": "={{ $(\"Call Enrichment API\").item.json.linkedin_url }}"
            },
            {
              "name": "company_size",
              "value": "={{ $(\"Call Enrichment API\").item.json.company_size }}"
            },
            {
              "name": "industry",
              "value": "={{ $(\"Call Enrichment API\").item.json.industry }}"
            },
            {
              "name": "intent",
              "value": "={{ $(\"Call Intent Classification API\").item.json.intent }}"
            },
            {
              "name": "confidence",
              "value": "={{ $(\"Call Intent Classification API\").item.json.confidence }}"
            }
          ]
        },
        "options": {
          "timeout": 10000
        }
      },
      "id": "4e027b46-d303-4b19-ba21-0a63a883c38e",
      "name": "Store Lead in DB",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1408,
        368
      ],
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://httpbin.org/post",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "text",
              "value": "=\ud83d\ude80 New Lead Captured!\n\n\ud83d\udc64 Name: {{ $(\"Webhook Trigger\").item.json.query.name || $(\"Webhook Trigger\").item.json.body.name }}\n\ud83d\udce7 Email: {{ $(\"Webhook Trigger\").item.json.query.email || $(\"Webhook Trigger\").item.json.body.email }}\n\ud83c\udfe2 Company: {{ $(\"Webhook Trigger\").item.json.query.company || $(\"Webhook Trigger\").item.json.body.company }}\n\ud83c\udfed Industry: {{ $(\"Call Enrichment API\").item.json.industry }}\n\ud83d\udcca Company Size: {{ $(\"Call Enrichment API\").item.json.company_size }}\n\ud83d\udd17 LinkedIn: {{ $(\"Call Enrichment API\").item.json.linkedin_url }}\n\ud83c\udfaf Intent: {{ $(\"Call Intent Classification API\").item.json.intent }}\n\ud83d\udcc8 Confidence: {{ $(\"Call Intent Classification API\").item.json.confidence }}\n\u2705 Status: Stored in DB\n\u23f0 Time: {{ $now }}"
            }
          ]
        },
        "options": {}
      },
      "id": "10484220-6692-4edd-8882-ae921ebb9a7f",
      "name": "Send Notification",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1632,
        368
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ { \"status\": \"success\", \"message\": \"Lead processed successfully\", \"lead\": { \"name\": $(\"Webhook Trigger\").item.json.query.name || $(\"Webhook Trigger\").item.json.body.name, \"email\": $(\"Webhook Trigger\").item.json.query.email || $(\"Webhook Trigger\").item.json.body.email, \"company\": $(\"Webhook Trigger\").item.json.query.company || $(\"Webhook Trigger\").item.json.body.company, \"intent\": $(\"Call Intent Classification API\").item.json.intent, \"confidence\": $(\"Call Intent Classification API\").item.json.confidence, \"linkedin_url\": $(\"Call Enrichment API\").item.json.linkedin_url, \"industry\": $(\"Call Enrichment API\").item.json.industry } } }}",
        "options": {
          "responseCode": 200
        }
      },
      "id": "6853dd90-6da9-4b82-83ec-4902f476caf1",
      "name": "Success Response",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        1856,
        368
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify({ \"status\": \"error\", \"message\": \"Pipeline failed. Check execution logs.\", \"code\": 500 }) }}",
        "options": {
          "responseCode": 500
        }
      },
      "id": "14b865a4-a301-492f-8022-465177781785",
      "name": "Error Response",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        512,
        784
      ]
    }
  ],
  "connections": {
    "Webhook Trigger": {
      "main": [
        [
          {
            "node": "Validate Input Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate Input Data": {
      "main": [
        [
          {
            "node": "Call Enrichment API",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Validation Failed Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Call Enrichment API": {
      "main": [
        [
          {
            "node": "Call Intent Classification API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Call Intent Classification API": {
      "main": [
        [
          {
            "node": "Store Lead in DB",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Store Lead in DB": {
      "main": [
        [
          {
            "node": "Send Notification",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Notification": {
      "main": [
        [
          {
            "node": "Success Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate"
  },
  "versionId": "588a54a0-f472-4966-b617-a95b95d0b1bb",
  "id": "1RshEoDtti1pClXb",
  "tags": [
    {
      "name": "Aviara Labs Assignment",
      "id": "Xh2adqV5E2vymJLJ",
      "updatedAt": "2026-05-23T00:19:59.559Z",
      "createdAt": "2026-05-23T00:19:59.559Z"
    }
  ]
}