{
  "name": "Qualify leads from Gemini chat to Google Sheets and Slack with self-optimization",
  "nodes": [
    {
      "id": "46451b10-ea57-483d-a07f-82ce9d7ce043",
      "name": "Chat Logic Brain",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        -672,
        400
      ]
    },
    {
      "id": "3ae26212-48b8-436a-9be0-3b697d9c461c",
      "name": "Scoring Logic",
      "type": "n8n-nodes-base.code",
      "position": [
        -688,
        128
      ]
    },
    {
      "id": "75180d9a-bb6c-4621-8edd-30e1a1e02b05",
      "name": "AI Council: Strategist",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        -528,
        128
      ]
    },
    {
      "id": "f7ff1666-0bca-4eb1-90a8-1f9cbc7529aa",
      "name": "Is High ROI?",
      "type": "n8n-nodes-base.if",
      "position": [
        -256,
        128
      ]
    },
    {
      "id": "141964e7-9f38-48c1-932f-d7985b764d3c",
      "name": "Log Lead to Spreadsheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        0,
        160
      ]
    },
    {
      "id": "2c06119e-9188-43f8-bbec-25d85a3bdd6e",
      "name": "Chat Session Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        -1328,
        288
      ]
    },
    {
      "id": "785ae002-59ec-4e23-b852-8e1f60d2cf42",
      "name": "Log Strategy to Backup",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        0,
        368
      ]
    },
    {
      "id": "216335ad-32bc-4d6c-8af1-a78e85b20dca",
      "name": "Notify Sales of Hot Lead",
      "type": "n8n-nodes-base.slack",
      "position": [
        0,
        0
      ]
    },
    {
      "id": "82b7adfe-03f2-4017-9f20-8d4685b5af64",
      "name": "Main Instructions",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2080,
        -96
      ],
      "parameters": {
        "width": 528,
        "height": 672,
        "content": "How it works\nThe template operates in two distinct phases:\n\nThe Lead Engine: A user interacts with a chat bubble. A Gemini-powered agent conversationally qualifies the lead (Name, Industry, Budget). A"
      }
    },
    {
      "id": "929cecbd-c42c-4cdf-b9ee-5466a6f9ec50",
      "name": "Lead Chat Trigger",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -1488,
        128
      ]
    },
    {
      "id": "0a97b388-c0b2-472a-98d1-da8d3e98981e",
      "name": "Qualify Lead Conversationally",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1312,
        128
      ]
    },
    {
      "id": "4cb94e2b-cad6-449a-a10f-059771d075b7",
      "name": "Extract Lead State",
      "type": "n8n-nodes-base.code",
      "position": [
        -1008,
        128
      ]
    },
    {
      "id": "ff010bc9-0899-4260-a75e-ba71c06ecfed",
      "name": "Lead Ingestion Group",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1536,
        48
      ],
      "parameters": {
        "width": 496,
        "height": 400,
        "content": "This section captures user input via chat and maintains a stateful conversation to qualify leads."
      }
    },
    {
      "id": "988a2dae-3e9a-4334-a72c-153464ca9ec0",
      "name": "Data Processing Group",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1024,
        48
      ],
      "parameters": {
        "width": 448,
        "height": 272,
        "content": "Extracts JSON data from the chat and validates that all required fields are present before scoring."
      }
    },
    {
      "id": "a6919265-c647-435b-ab8f-3207f6af7c5d",
      "name": "Audit Analyst Brain",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        -1040,
        928
      ]
    },
    {
      "id": "d1316dcb-fb51-4fc1-a014-acf704224e2a",
      "name": "Audit Lead Performance",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1024,
        720
      ]
    },
    {
      "id": "3b9aad85-8753-4ff2-aff1-1bfd45c3bcad",
      "name": "Send Optimization Report",
      "type": "n8n-nodes-base.slack",
      "position": [
        -704,
        720
      ]
    },
    {
      "id": "19e2340e-242e-4e7d-a4ac-0d3f7d095d69",
      "name": "Self-Optimization Group",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1456,
        656
      ],
      "parameters": {
        "width": 944,
        "height": 416,
        "content": "Feedback Loop: An autonomous loop that audits daily lead performance to suggest prompt improvements."
      }
    },
    {
      "id": "9147a451-5e38-44c9-865b-009c4c8b9698",
      "name": "Output Group",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -96,
        -96
      ],
      "parameters": {
        "width": 272,
        "height": 640,
        "content": "Logs lead data to Google Sheets and alerts the team via Slack."
      }
    },
    {
      "id": "b96a8cb7-74da-4320-a4f3-a33c41450052",
      "name": "Check if Lead is Qualified",
      "type": "n8n-nodes-base.filter",
      "position": [
        -832,
        128
      ]
    },
    {
      "id": "bd7e8fee-2b41-4704-81c2-42ad3560dc89",
      "name": "Daily Performance Audit Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -1408,
        720
      ]
    },
    {
      "id": "c156f503-ef8b-4487-8a5d-21254ce1b904",
      "name": "Send Response to Chat Interface",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        -1184,
        288
      ]
    },
    {
      "id": "7ffb5f5b-ff3b-42f7-8e40-9420da81e7fa",
      "name": "Fetch Historical Lead Data",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -1232,
        720
      ]
    },
    {
      "id": "97b8118a-2057-4d39-b6ef-91c5e079d45f",
      "name": "AI Council Group",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -560,
        48
      ],
      "parameters": {
        "width": 448,
        "height": 240,
        "content": "Uses Gemini to generate industry-specific growth tactics for qualified leads."
      }
    }
  ],
  "connections": {
    "Is High ROI?": {
      "main": [
        [
          {
            "node": "Log Lead to Spreadsheet",
            "type": "main",
            "index": 0
          },
          {
            "node": "Notify Sales of Hot Lead",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Log Strategy to Backup",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Scoring Logic": {
      "main": [
        [
          {
            "node": "AI Council: Strategist",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Chat Logic Brain": {
      "ai_languageModel": [
        [
          {
            "node": "Qualify Lead Conversationally",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "AI Council: Strategist",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Lead Chat Trigger": {
      "main": [
        [
          {
            "node": "Qualify Lead Conversationally",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Lead State": {
      "main": [
        [
          {
            "node": "Check if Lead is Qualified",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Audit Analyst Brain": {
      "ai_languageModel": [
        [
          {
            "node": "Audit Lead Performance",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Chat Session Memory": {
      "ai_memory": [
        [
          {
            "node": "Qualify Lead Conversationally",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "AI Council: Strategist": {
      "main": [
        [
          {
            "node": "Is High ROI?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Audit Lead Performance": {
      "main": [
        [
          {
            "node": "Send Optimization Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if Lead is Qualified": {
      "main": [
        [
          {
            "node": "Scoring Logic",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Historical Lead Data": {
      "main": [
        [
          {
            "node": "Audit Lead Performance",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Qualify Lead Conversationally": {
      "main": [
        [
          {
            "node": "Extract Lead State",
            "type": "main",
            "index": 0
          },
          {
            "node": "Send Response to Chat Interface",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Daily Performance Audit Trigger": {
      "main": [
        [
          {
            "node": "Fetch Historical Lead Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}