{
  "name": "AI lead qualification (TestedFlows)",
  "nodes": [
    {
      "parameters": {
        "formTitle": "Tell us about your project",
        "formDescription": "We reply within one business day.",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Name",
              "requiredField": true
            },
            {
              "fieldLabel": "Work email",
              "fieldType": "email",
              "requiredField": true
            },
            {
              "fieldLabel": "Company",
              "requiredField": true
            },
            {
              "fieldLabel": "Company size",
              "fieldType": "dropdown",
              "fieldOptions": {
                "values": [
                  {
                    "option": "1-10"
                  },
                  {
                    "option": "11-50"
                  },
                  {
                    "option": "51-200"
                  },
                  {
                    "option": "200+"
                  }
                ]
              },
              "requiredField": true
            },
            {
              "fieldLabel": "Monthly budget",
              "fieldType": "dropdown",
              "fieldOptions": {
                "values": [
                  {
                    "option": "Under $500"
                  },
                  {
                    "option": "$500 - $2,000"
                  },
                  {
                    "option": "$2,000 - $10,000"
                  },
                  {
                    "option": "Over $10,000"
                  }
                ]
              },
              "requiredField": true
            },
            {
              "fieldLabel": "What do you want to automate?",
              "fieldType": "textarea",
              "requiredField": true
            }
          ]
        },
        "options": {}
      },
      "name": "Lead form",
      "type": "n8n-nodes-base.formTrigger",
      "typeVersion": 2.6,
      "position": [
        0,
        300
      ],
      "webhookId": "842f1494-08be-4f21-927f-df283176b93d",
      "id": "db91a1d6-c643-42d2-954c-e124d1c743da"
    },
    {
      "parameters": {
        "text": "=Company: {{ $json.Company }}\nCompany size: {{ $json['Company size'] }}\nMonthly budget: {{ $json['Monthly budget'] }}\nRequest: {{ $json['What do you want to automate?'] }}",
        "attributes": {
          "attributes": [
            {
              "name": "score",
              "type": "number",
              "description": "Lead quality from 1 (poor fit) to 10 (ideal fit). Ideal: 11+ employees, budget over $500 a month, a clear process to automate.",
              "required": true
            },
            {
              "name": "tier",
              "description": "One of: hot, warm, cold",
              "required": true
            },
            {
              "name": "reason",
              "description": "One sentence explaining the score",
              "required": true
            }
          ]
        },
        "options": {
          "systemPromptTemplate": "You qualify inbound leads for an automation agency. Score each lead using only the information given. Be strict: vague requests or tiny budgets score low."
        }
      },
      "name": "Score lead with AI",
      "type": "@n8n/n8n-nodes-langchain.informationExtractor",
      "typeVersion": 1.2,
      "position": [
        260,
        300
      ],
      "id": "2853cb0f-176d-4ea7-891d-999e6cc2a5a1"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-5-mini"
        },
        "options": {}
      },
      "name": "OpenAI model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.3,
      "position": [
        260,
        520
      ],
      "id": "541772c1-2ea7-4a83-81c7-d65487daee83"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "a1",
              "name": "submitted_at",
              "value": "={{ $now.toISO() }}",
              "type": "string"
            },
            {
              "id": "a2",
              "name": "name",
              "value": "={{ $('Lead form').item.json.Name }}",
              "type": "string"
            },
            {
              "id": "a3",
              "name": "email",
              "value": "={{ $('Lead form').item.json['Work email'] }}",
              "type": "string"
            },
            {
              "id": "a4",
              "name": "company",
              "value": "={{ $('Lead form').item.json.Company }}",
              "type": "string"
            },
            {
              "id": "a5",
              "name": "size",
              "value": "={{ $('Lead form').item.json['Company size'] }}",
              "type": "string"
            },
            {
              "id": "a6",
              "name": "budget",
              "value": "={{ $('Lead form').item.json['Monthly budget'] }}",
              "type": "string"
            },
            {
              "id": "a7",
              "name": "request",
              "value": "={{ $('Lead form').item.json['What do you want to automate?'] }}",
              "type": "string"
            },
            {
              "id": "a8",
              "name": "score",
              "value": "={{ $json.output.score }}",
              "type": "number"
            },
            {
              "id": "a9",
              "name": "tier",
              "value": "={{ $json.output.tier }}",
              "type": "string"
            },
            {
              "id": "a10",
              "name": "reason",
              "value": "={{ $json.output.reason }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "name": "Prepare lead row",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        560,
        300
      ],
      "id": "d5455500-fd3d-474e-957c-b854b58a2d66"
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": ""
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "columns": {
          "mappingMode": "autoMapInputData",
          "value": {},
          "matchingColumns": [],
          "schema": []
        },
        "options": {},
        "authentication": "oAuth2"
      },
      "name": "Log lead in Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        800,
        300
      ],
      "id": "e6b25b61-76de-4c9d-a996-55836bd940c2"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "c1",
              "leftValue": "={{ $('Prepare lead row').item.json.score }}",
              "rightValue": 7,
              "operator": {
                "type": "number",
                "operation": "gte"
              }
            }
          ],
          "combinator": "and"
        },
        "looseTypeValidation": true,
        "options": {}
      },
      "name": "Score 7 or higher?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        1040,
        300
      ],
      "id": "beee774d-bdc3-4d6c-b9ee-6cea5e24e46f"
    },
    {
      "parameters": {
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "name",
          "value": "#sales"
        },
        "text": "=New hot lead ({{ $('Prepare lead row').item.json.score }}/10): {{ $('Prepare lead row').item.json.name }} at {{ $('Prepare lead row').item.json.company }}\nBudget: {{ $('Prepare lead row').item.json.budget }}\nWhy: {{ $('Prepare lead row').item.json.reason }}\nEmail: {{ $('Prepare lead row').item.json.email }}",
        "otherOptions": {}
      },
      "name": "Alert sales in Slack",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.3,
      "position": [
        1280,
        200
      ],
      "id": "7615de54-e5b3-4a0a-b84f-91cdc54e5754",
      "webhookId": "d16ac34d-bbb7-4a3c-b788-40f57570c0af"
    },
    {
      "parameters": {},
      "name": "No alert needed",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1280,
        400
      ],
      "id": "2c37bb33-fce9-4198-a7ac-2edba642e1e9"
    }
  ],
  "connections": {
    "Lead form": {
      "main": [
        [
          {
            "node": "Score lead with AI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI model": {
      "ai_languageModel": [
        [
          {
            "node": "Score lead with AI",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Score lead with AI": {
      "main": [
        [
          {
            "node": "Prepare lead row",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare lead row": {
      "main": [
        [
          {
            "node": "Log lead in Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log lead in Google Sheets": {
      "main": [
        [
          {
            "node": "Score 7 or higher?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Score 7 or higher?": {
      "main": [
        [
          {
            "node": "Alert sales in Slack",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No alert needed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": false,
    "source": "https://testedflows.com/templates/"
  }
}