{
  "name": "Capture, score and route Gmail leads with Groq Llama 3.3, Supabase and Slack",
  "nodes": [
    {
      "id": "2cc8f06e-6851-43d8-b5bd-bc1e021f49f3",
      "name": "Fetch Unscored Leads1",
      "type": "n8n-nodes-base.supabase",
      "position": [
        14320,
        6688
      ]
    },
    {
      "id": "39b0e8d8-f1a8-42c1-8e88-6e0788e76976",
      "name": "Map AI Score Output1",
      "type": "n8n-nodes-base.set",
      "position": [
        15040,
        6672
      ]
    },
    {
      "id": "027c0a71-556d-46ae-bf52-edcc25f1d96c",
      "name": "Update Lead Score1",
      "type": "n8n-nodes-base.supabase",
      "position": [
        15280,
        6672
      ]
    },
    {
      "id": "1dbc4417-26f5-46c8-9d56-3f67b03e84cf",
      "name": "Fetch Scored Leads1",
      "type": "n8n-nodes-base.supabase",
      "position": [
        14352,
        7536
      ]
    },
    {
      "id": "7a061ce4-7af5-46f4-8ab9-0323d11463ff",
      "name": "Check Message Exists1",
      "type": "n8n-nodes-base.if",
      "position": [
        14544,
        7536
      ]
    },
    {
      "id": "76d09830-2494-4cf8-84f6-f032d231dda8",
      "name": "LLM (Classification)1",
      "type": "@n8n/n8n-nodes-langchain.lmChatGroq",
      "position": [
        14784,
        7712
      ]
    },
    {
      "id": "2bdc1a6f-47f1-43f0-a746-636c5f09a043",
      "name": "Route Lead by Category1",
      "type": "n8n-nodes-base.switch",
      "position": [
        15376,
        7472
      ]
    },
    {
      "id": "f1120002-6c2f-4504-aa01-19598d45cdd7",
      "name": "Send to Sales Channel1",
      "type": "n8n-nodes-base.slack",
      "position": [
        15776,
        7280
      ]
    },
    {
      "id": "f5cff006-d0b6-4d55-b88c-eea24bbef6b4",
      "name": "Send to Support Channel1",
      "type": "n8n-nodes-base.slack",
      "position": [
        15776,
        7440
      ]
    },
    {
      "id": "a58699b2-cfbe-4731-a838-a36a3e9dc7ce",
      "name": "Send to Billing Channel1",
      "type": "n8n-nodes-base.slack",
      "position": [
        15776,
        7600
      ]
    },
    {
      "id": "f07857ae-5984-4815-9e72-208f45b26598",
      "name": "Store Lead in Database1",
      "type": "n8n-nodes-base.supabase",
      "position": [
        13632,
        6688
      ]
    },
    {
      "id": "3701fe80-d427-4bd7-9357-19e1ec440819",
      "name": "Notify New Lead (Slack)1",
      "type": "n8n-nodes-base.slack",
      "position": [
        13424,
        6688
      ]
    },
    {
      "id": "b22aa137-9dee-4933-9855-b033afee0c99",
      "name": "Gmail Trigger1",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        12336,
        6688
      ]
    },
    {
      "id": "d383d6cb-a90b-40f8-886f-7bbd52832d51",
      "name": "Get a message1",
      "type": "n8n-nodes-base.gmail",
      "position": [
        12560,
        6688
      ]
    },
    {
      "id": "cda71979-9c16-4e58-a2eb-2ee0a30e9121",
      "name": "Validate Lead Data1",
      "type": "n8n-nodes-base.if",
      "position": [
        13008,
        6688
      ]
    },
    {
      "id": "dd730765-6ef8-4fe8-aac3-9e5f473242e4",
      "name": "Normalize Incoming Lead Data1",
      "type": "n8n-nodes-base.set",
      "position": [
        12784,
        6688
      ]
    },
    {
      "id": "12a386cf-7f36-4a73-9627-38af148f684d",
      "name": "End1",
      "type": "n8n-nodes-base.noOp",
      "position": [
        15776,
        7776
      ]
    },
    {
      "id": "54c1f6e3-f6a3-4be1-8a39-9547d38f7ac8",
      "name": "AI Lead Scoring Engine1",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        14592,
        6672
      ]
    },
    {
      "id": "03013e21-1f50-4acf-ab9a-0ea9d46f0222",
      "name": "LLM (Scoring)1",
      "type": "@n8n/n8n-nodes-langchain.lmChatGroq",
      "position": [
        14592,
        6912
      ]
    },
    {
      "id": "789358b1-095e-4306-8133-728c794b16a2",
      "name": "AI Lead Classification Engine1",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        14784,
        7504
      ]
    },
    {
      "id": "f130f6a8-190c-4a1a-ba5d-cde04f74636b",
      "name": "Structured Output Parser1",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        14752,
        6912
      ]
    },
    {
      "id": "d554b89c-9760-480a-80f3-f81d4f0358fd",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        11520,
        6480
      ],
      "parameters": {
        "width": 624,
        "height": 592,
        "content": "### AI lead scoring and smart routing with Gmail, Supabase, OpenAI, and Slack\n\nAutomatically capture leads from Gmail, score them using AI, and route them to the correct team channels.\n\n**What it does"
      }
    },
    {
      "id": "4bc46077-798f-4e6f-8c04-305e10f0dd72",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        12192,
        6480
      ],
      "parameters": {
        "width": 1088,
        "height": 592,
        "content": "## Step 1 – Lead capture and normalization\n\nCaptures incoming emails, extracts key fields (name, email, message, thread), and validates required data before processing.\n"
      }
    },
    {
      "id": "cacd6af6-053a-4e35-ad37-b7e196840fa3",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        13296,
        6480
      ],
      "parameters": {
        "width": 672,
        "height": 592,
        "content": "## Step 2 – Lead storage and notification\n\nSends a real-time Slack alert for new leads and stores structured lead data in Supabase with status tracking.\n"
      }
    },
    {
      "id": "f1365458-cb34-44a8-8338-1b489aa99a91",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        15280,
        7104
      ],
      "parameters": {
        "width": 848,
        "height": 832,
        "content": "## Step 5 – Smart routing and team notifications\n\nRoutes leads based on AI classification and sends them to the correct Slack channel for faster response and handling.\n"
      }
    },
    {
      "id": "711c1a39-a453-4740-bd99-911bb4592c35",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        14000,
        7104
      ],
      "parameters": {
        "width": 1248,
        "height": 832,
        "content": "## Step 4 – Lead qualification and classification\n\nFilters scored leads, ensures valid messages exist, and classifies each lead into categories like sales, support, or billing.\n"
      }
    },
    {
      "id": "e05e03da-8f1a-4a17-89e4-f21fc98fec92",
      "name": "Sticky Note11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        14000,
        6480
      ],
      "parameters": {
        "width": 1616,
        "height": 592,
        "content": "## Step 3 – AI lead scoring pipeline\n\nFetches unscored leads, evaluates them using AI scoring logic, and updates the database with score and status.\n"
      }
    },
    {
      "id": "2b8de2bd-cf17-4454-9267-23a53b0605e0",
      "name": "Wait1",
      "type": "n8n-nodes-base.wait",
      "position": [
        14048,
        6688
      ]
    }
  ],
  "connections": {
    "Wait1": {
      "main": [
        [
          {
            "node": "Fetch Unscored Leads1",
            "type": "main",
            "index": 0
          },
          {
            "node": "Fetch Scored Leads1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get a message1": {
      "main": [
        [
          {
            "node": "Normalize Incoming Lead Data1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail Trigger1": {
      "main": [
        [
          {
            "node": "Get a message1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "LLM (Scoring)1": {
      "ai_languageModel": [
        [
          {
            "node": "AI Lead Scoring Engine1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Scored Leads1": {
      "main": [
        [
          {
            "node": "Check Message Exists1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate Lead Data1": {
      "main": [
        [
          {
            "node": "Notify New Lead (Slack)1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Map AI Score Output1": {
      "main": [
        [
          {
            "node": "Update Lead Score1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Message Exists1": {
      "main": [
        [
          {
            "node": "AI Lead Classification Engine1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Unscored Leads1": {
      "main": [
        [
          {
            "node": "AI Lead Scoring Engine1",
            "type": "main",
            "index": 0
          },
          {
            "node": "Map AI Score Output1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "LLM (Classification)1": {
      "ai_languageModel": [
        [
          {
            "node": "AI Lead Classification Engine1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "AI Lead Scoring Engine1": {
      "main": [
        [
          {
            "node": "Map AI Score Output1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route Lead by Category1": {
      "main": [
        [
          {
            "node": "Send to Sales Channel1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send to Support Channel1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send to Billing Channel1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "End1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Store Lead in Database1": {
      "main": [
        [
          {
            "node": "Wait1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Notify New Lead (Slack)1": {
      "main": [
        [
          {
            "node": "Store Lead in Database1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser1": {
      "ai_outputParser": [
        [
          {
            "node": "AI Lead Scoring Engine1",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Normalize Incoming Lead Data1": {
      "main": [
        [
          {
            "node": "Validate Lead Data1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Lead Classification Engine1": {
      "main": [
        [
          {
            "node": "Route Lead by Category1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}