{
  "name": "Gmail Lead Notification to Slack",
  "nodes": [
    {
      "parameters": {
        "pollTimes": {
          "item": [{ "mode": "everyMinute" }]
        },
        "filters": {
          "readStatus": "unread",
          "labelIds": ["INBOX"]
        },
        "options": {}
      },
      "id": "glts0001-0001-4000-8000-000000000001",
      "name": "Watch Inbox for Leads",
      "type": "n8n-nodes-base.gmailTrigger",
      "typeVersion": 1,
      "position": [240, 300]
    },
    {
      "parameters": {
        "model": "gpt-4o-mini",
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "You are a sales assistant. Read this email and determine if it is a potential sales lead or business inquiry. Respond in JSON: {\"isLead\": true|false, \"name\": \"...\", \"company\": \"...\", \"interest\": \"brief summary\", \"urgency\": \"low|medium|high\"}."
            },
            {
              "role": "user",
              "content": "From: {{ $json.from }}\\nSubject: {{ $json.subject }}\\n\\n{{ $json.text }}"
            }
          ]
        },
        "options": {
          "temperature": 0.1,
          "maxTokens": 300
        }
      },
      "id": "glts0001-0002-4000-8000-000000000002",
      "name": "Classify as Lead",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1,
      "position": [460, 300]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "field1",
              "name": "lead",
              "value": "={{ JSON.parse($json.message.content) }}",
              "type": "object"
            }
          ]
        },
        "options": {}
      },
      "id": "glts0001-0003-4000-8000-000000000003",
      "name": "Parse Lead Data",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3,
      "position": [680, 300]
    },
    {
      "parameters": {
        "conditions": {
          "options": { "caseSensitive": false, "leftValue": "", "typeValidation": "strict" },
          "conditions": [
            {
              "id": "cond1",
              "leftValue": "={{ $json.lead.isLead }}",
              "rightValue": true,
              "operator": { "type": "boolean", "operation": "true" }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "glts0001-0004-4000-8000-000000000004",
      "name": "Is a Lead?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [900, 300]
    },
    {
      "parameters": {
        "url": "={{ $env.SLACK_WEBHOOK_URL }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [{ "name": "Content-Type", "value": "application/json" }]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "text",
              "value": "=:email: *New Lead Detected!*\\n*Name:* {{ $json.lead.name }}\\n*Company:* {{ $json.lead.company }}\\n*Urgency:* {{ $json.lead.urgency }}\\n*Interest:* {{ $json.lead.interest }}"
            }
          ]
        },
        "options": {}
      },
      "id": "glts0001-0005-4000-8000-000000000005",
      "name": "Post to Slack",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [1120, 200]
    }
  ],
  "connections": {
    "Watch Inbox for Leads": {
      "main": [[{ "node": "Classify as Lead", "type": "main", "index": 0 }]]
    },
    "Classify as Lead": {
      "main": [[{ "node": "Parse Lead Data", "type": "main", "index": 0 }]]
    },
    "Parse Lead Data": {
      "main": [[{ "node": "Is a Lead?", "type": "main", "index": 0 }]]
    },
    "Is a Lead?": {
      "main": [
        [{ "node": "Post to Slack", "type": "main", "index": 0 }],
        []
      ]
    }
  },
  "active": false,
  "settings": { "executionOrder": "v1" },
  "meta": {},
  "pinData": {}
}
