AutomationFlowsMarketing & Ads › Leadflow AI — 01 Intake, Qualification and Routing

Leadflow AI — 01 Intake, Qualification and Routing

LeadFlow AI — 01 Intake, Qualification and Routing. Uses httpRequest. Webhook trigger; 9 nodes.

Webhook trigger★★★★☆ complexity9 nodesHTTP Request
Marketing & Ads Trigger: Webhook Nodes: 9 Complexity: ★★★★☆ Added:

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "name": "LeadFlow AI \u2014 01 Intake, Qualification and Routing",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "leadflow/intake",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "3bf79d9d-e05a-49d9-b34a-4f8df01cafa9",
      "name": "Inbound Lead Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "jsCode": "const envelope = $json.body ?? $json;\nconst headers = $json.headers ?? {};\nconst pick = (...values) => values.find((v) => v !== undefined && v !== null && String(v).trim() !== '');\nconst text = (v) => v === undefined || v === null ? '' : String(v).trim();\n\nlet source = text(pick(envelope.source, envelope.channel, headers['x-lead-source'], headers['X-Lead-Source'], 'form')).toLowerCase();\nlet data = envelope;\n\n// WhatsApp Cloud API payload\nif (envelope.object === 'whatsapp_business_account' || envelope.entry?.[0]?.changes?.[0]?.value?.messages?.[0]) {\n  source = 'whatsapp';\n  const value = envelope.entry?.[0]?.changes?.[0]?.value ?? {};\n  const message = value.messages?.[0] ?? {};\n  const contact = value.contacts?.[0] ?? {};\n  data = {\n    source_lead_id: message.id,\n    full_name: contact.profile?.name,\n    phone: message.from,\n    message: message.text?.body ?? message.button?.text ?? message.interactive?.button_reply?.title ?? '',\n    language: '',\n  };\n}\n\n// Common inbound email webhook fields (Mailgun, SendGrid, Postmark or custom parser)\nif (source.includes('email') || envelope['sender'] || envelope['from'] || envelope['From']) {\n  source = source === 'form' ? 'email' : source;\n  data = {\n    ...envelope,\n    full_name: pick(envelope.full_name, envelope.name, envelope.sender_name, envelope.from_name),\n    email: pick(envelope.email, envelope.sender, envelope.from, envelope.From),\n    message: pick(envelope.message, envelope.text, envelope['body-plain'], envelope.TextBody, envelope.subject),\n    source_lead_id: pick(envelope.source_lead_id, envelope['Message-Id'], envelope.MessageID, envelope.message_id),\n  };\n}\n\n// Enriched Meta/Facebook lead payload or generic advertising connector\nif (source.includes('meta') || source.includes('facebook') || envelope.leadgen_id) {\n  source = 'meta_ads';\n  data = {\n    ...envelope,\n    source_lead_id: pick(envelope.source_lead_id, envelope.leadgen_id, envelope.id),\n    full_name: pick(envelope.full_name, envelope.name),\n    email: envelope.email,\n    phone: pick(envelope.phone, envelope.phone_number),\n    company: envelope.company,\n    message: pick(envelope.message, envelope.need, envelope.project),\n    campaign: pick(envelope.campaign, envelope.campaign_name, envelope.ad_name),\n  };\n}\n\nconst lead = {\n  source,\n  source_lead_id: text(pick(data.source_lead_id, data.lead_id, data.id)),\n  full_name: text(pick(data.full_name, data.name, data.contact_name, data.first_name && data.last_name ? `${data.first_name} ${data.last_name}` : data.first_name)),\n  email: text(pick(data.email, data.email_address)),\n  phone: text(pick(data.phone, data.phone_number, data.mobile, data.whatsapp)),\n  company: text(pick(data.company, data.company_name, data.organization)),\n  job_title: text(pick(data.job_title, data.position, data.role)),\n  message: text(pick(data.message, data.need, data.project, data.description, data.text, data.subject)),\n  budget: text(pick(data.budget, data.budget_range)),\n  timeline: text(pick(data.timeline, data.deadline, data.urgency)),\n  country: text(pick(data.country, data.location)),\n  language: text(pick(data.language, data.locale)),\n  campaign: text(pick(data.campaign, data.utm_campaign)),\n  assigned_to: text(data.assigned_to),\n  raw_payload: envelope,\n};\n\nreturn [{ json: { lead, received_at: new Date().toISOString() } }];"
      },
      "id": "26cffe24-e797-4630-a855-5621e7c9fa5f",
      "name": "Normalize Lead",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        240,
        0
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://leadflow-api:8000/api/leads/upsert",
        "options": {
          "timeout": 30000
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "X-LeadFlow-Key",
              "value": "={{ $env.LEADFLOW_INTERNAL_API_KEY }}"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ { lead: $json.lead } }}"
      },
      "id": "43df7c82-8311-4898-9524-4353ab2af840",
      "name": "Deduplicate and Store",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        500,
        0
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=http://leadflow-api:8000/api/leads/{{$json.lead_id}}/qualify",
        "options": {
          "timeout": 60000
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "X-LeadFlow-Key",
              "value": "={{ $env.LEADFLOW_INTERNAL_API_KEY }}"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ {} }}"
      },
      "id": "157d3d38-3c17-4f84-a36e-216b16336e26",
      "name": "AI Qualification",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        760,
        0
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://leadflow-api:8000/api/crm/sync",
        "options": {
          "timeout": 30000
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "X-LeadFlow-Key",
              "value": "={{ $env.LEADFLOW_INTERNAL_API_KEY }}"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ { lead_id: $json.lead_id } }}"
      },
      "id": "d24798c9-ef0d-4e38-8562-5ef18a1a06b4",
      "name": "Sync CRM",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1020,
        0
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://leadflow-api:8000/api/messages/send-initial",
        "options": {
          "timeout": 30000
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "X-LeadFlow-Key",
              "value": "={{ $env.LEADFLOW_INTERNAL_API_KEY }}"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ { lead_id: $json.lead_id } }}"
      },
      "id": "60063959-d17f-4961-8d3c-7ff5df7349b1",
      "name": "Send Personalized Reply",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1280,
        0
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://leadflow-api:8000/api/followups/schedule",
        "options": {
          "timeout": 30000
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "X-LeadFlow-Key",
              "value": "={{ $env.LEADFLOW_INTERNAL_API_KEY }}"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ { lead_id: $json.lead_id } }}"
      },
      "id": "2d87544e-0f3f-4db7-a48e-1e994dcdcdd6",
      "name": "Schedule Follow-ups",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1540,
        0
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://leadflow-api:8000/api/notifications/send-sales",
        "options": {
          "timeout": 30000
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "X-LeadFlow-Key",
              "value": "={{ $env.LEADFLOW_INTERNAL_API_KEY }}"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ { lead_id: $json.lead_id } }}"
      },
      "id": "6334ab9f-c0e9-4c0e-8237-5dda324c72b0",
      "name": "Notify Sales Team",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1800,
        0
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ { ok: true, lead_id: $json.lead_id || null, message: \"LeadFlow AI a accept\u00e9 et trait\u00e9 le prospect.\" } }}",
        "options": {
          "responseCode": 200
        }
      },
      "id": "3731b022-65c6-47d3-8721-e9247fc14100",
      "name": "Return Accepted",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.4,
      "position": [
        2060,
        0
      ]
    }
  ],
  "connections": {
    "Inbound Lead Webhook": {
      "main": [
        [
          {
            "node": "Normalize Lead",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize Lead": {
      "main": [
        [
          {
            "node": "Deduplicate and Store",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Deduplicate and Store": {
      "main": [
        [
          {
            "node": "AI Qualification",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Qualification": {
      "main": [
        [
          {
            "node": "Sync CRM",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Sync CRM": {
      "main": [
        [
          {
            "node": "Send Personalized Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Personalized Reply": {
      "main": [
        [
          {
            "node": "Schedule Follow-ups",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Follow-ups": {
      "main": [
        [
          {
            "node": "Notify Sales Team",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Notify Sales Team": {
      "main": [
        [
          {
            "node": "Return Accepted",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "57b51efd-4eb7-4978-bcbb-679ef26c085f",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "tags": [],
  "id": "965a2878-52dd-44af-b93f-288c59dbb3ef"
}
Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

LeadFlow AI — 01 Intake, Qualification and Routing. Uses httpRequest. Webhook trigger; 9 nodes.

Source: https://github.com/1liasx/leadflow-ai/blob/main/workflows/01_intake_qualification_routing.json — original creator credit. Request a take-down →

More Marketing & Ads workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

Marketing & Ads

This workflow automates bulk email campaigns with built-in validation, deliverability protection, and smart send-time optimization.

HTTP Request, Postgres, Gmail
Marketing & Ads

Universal Lead Processing Workflow. Uses googleSheets, gmail, httpRequest, gmailTrigger. Webhook trigger; 34 nodes.

Google Sheets, Gmail, HTTP Request +1
Marketing & Ads

This workflow turns Feishu bot messages into a human-in-the-loop short-video production pipeline, using Tavily for web search, DeepSeek for topic and script generation, Jimeng AI for text-to-video, an

HTTP Request
Marketing & Ads

This workflow is designed to manage the assignment and validation of unique QR code coupons within a lead generation system with SuiteCRM.

HTTP Request, Form Trigger, Google Sheets +1
Marketing & Ads

This workflow acts as an instant SDR that replies to new inbound leads across multiple channels in real time. It first captures and normalizes all incoming lead data into a unified structure. The work

Google Sheets, HTTP Request, Gmail +1