{
  "nodes": [
    {
      "id": "b5ee413f-2a78-4193-acf7-e5994da7f26d",
      "name": "Get domain from email",
      "type": "n8n-nodes-base.set",
      "position": [
        -720,
        700
      ],
      "parameters": {
        "values": {
          "string": [
            {
              "name": "domain",
              "value": "={ { $json.body.email.split(\"@\")[1] } }"
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 2
    },
    {
      "id": "cf045629-7f26-4d67-a620-30e9860f6005",
      "name": "Verify professional email",
      "type": "n8n-nodes-base.code",
      "position": [
        -540,
        700
      ],
      "parameters": {
        "jsCode": "const freemail_list = [\"hitmail.com\",\"rxdoc.biz\",...];\n\nfunction isFreeEmailProvider(domain) {\n    return freemail_list.includes(domain.toLowerCase());\n}\n\nreturn {\"free_email\":isFreeEmailProvider($json.domain)}\n",
        "typeVersion": 2
      }
    },
    {
      "id": "194b1d8d-13e6-4528-89ac-998f1a96393c",
      "name": "Qualify Account",
      "type": "n8n-nodes-base.code",
      "position": [
        220,
        700
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "// this code will route lead in companies with more than 100 employees to 1:1 demo and other leads to group demo\n\n$input.item.json.result = 2;\ncompany_size = 0;\nif ($input?.item?.json?.company_size){\ncompany_size = $input.item.json.company_size;}\nif (company_size > 100) {\n  $input.item.json.result = 1;\n}\nreturn $input.item;"
      }
    },
    {
      "id": "42277c12-825d-44d1-9eed-747c47386c36",
      "name": "Simplify Datagma Output",
      "type": "n8n-nodes-base.set",
      "position": [
        -20,
        700
      ],
      "parameters": {
        "values": {
          "string": [
            {
              "name": "company_size",
              "value": "={ { parseInt(($json.company.premium.employeesAmountInLinkedin).replace(/\\s/g, ''), 10) } }"
            },
            {
              "name": "industry",
              "value": "={ { $json.company.premium.industries } }"
            },
            {
              "name": "founded",
              "value": "={ { $json.company.premium.founded } }"
            },
            {
              "name": "linkedin Url",
              "value": "={ { $json.company.premium.url } }"
            },
            {
              "name": "company_description",
              "value": "={ { $json.company.premium.about } }"
            },
            {
              "name": "funding_amount",
              "value": "={ { $json.company.full.cards.fundingRoundsList[2].moneyRaised.value } }"
            },
            {
              "name": "company_revenue",
              "value": "={ { $json.company.full.cards.overviewFields.revenueRange } }"
            },
            {
              "name": "companyName",
              "value": "={ { $json.company.premium.name } }"
            },
            {
              "name": "free_mail_provider",
              "value": "={ { $('Verify professional email').item.json.free_email } }"
            }
          ]
        },
        "options": {},
        "keepOnlySet": true
      }
    },
    {
      "id": "233487a5-9a56-4f18-8fe2-8046a0c3a695",
      "name": "Enrich with Datagma",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -260,
        700
      ],
      "parameters": {
        "url": "https://gateway.datagma.net/api/ingress/v2/full",
        "options": {},
        "sendQuery": true,
        "sendHeaders": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "data",
              "value": "={ { $('Get domain from email').item.json.domain } }"
            },
            {
              "name": "companyPremium",
              "value": "true"
            },
            {
              "name": "companyFull",
              "value": "true"
            },
            {
              "name": "companyEmployees",
              "value": "false"
            },
            {
              "name": "employeeCountry",
              "value": "US"
            },
            {
              "name": "apiId",
              "value": "$env.DATAGMA_API_KEY"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "accept",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.1
    },
    {
      "id": "39511666-ad16-4666-ab35-be393aa53d0d",
      "name": "Receive form submission from Webflow",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -920,
        700
      ],
      "parameters": {
        "path": "6545426b-ff78-47af-8e20-a6e9f5259c8e",
        "options": {},
        "httpMethod": "POST",
        "responseMode": "responseNode"
      },
      "typeVersion": 1
    },
    {
      "id": "980632d5-d495-488a-9af0-a6b64ccfa5e6",
      "name": "Send result to Webflow",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        520,
        700
      ],
      "parameters": {
        "options": {
          "responseCode": 200,
          "responseHeaders": {
            "entries": [
              {
                "name": "Access-Control-Allow-Origin",
                "value": "*"
              },
              {
                "name": "Access-Control-Allow-Headers",
                "value": "Content-Type"
              },
              {
                "name": "Access-Control-Allow-Methods",
                "value": "GET, POST"
              }
            ]
          }
        },
        "respondWith": "json",
        "responseBody": "={\"result\":{ { $json[\"result\"] } }}"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Qualify Account": {
      "main": [
        [
          {
            "node": "Send result to Webflow",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Enrich with Datagma": {
      "main": [
        [
          {
            "node": "Simplify Datagma Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get domain from email": {
      "main": [
        [
          {
            "node": "Verify professional email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simplify Datagma Output": {
      "main": [
        [
          {
            "node": "Qualify Account",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Verify professional email": {
      "main": [
        [
          {
            "node": "Enrich with Datagma",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Receive form submission from Webflow": {
      "main": [
        [
          {
            "node": "Get domain from email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}