{
  "name": "AI Lead Qualification",
  "nodes": [
    {
      "parameters": {
        "formTitle": "AI Project Enquiry",
        "formDescription": "Tell us a little about your project.",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Name"
            },
            {
              "fieldLabel": "Company"
            },
            {
              "fieldLabel": "Email",
              "fieldType": "email"
            },
            {
              "fieldLabel": "Company Size",
              "fieldType": "dropdown",
              "fieldOptions": {
                "values": [
                  {
                    "option": "1-10"
                  },
                  {
                    "option": "11-50"
                  },
                  {
                    "option": "101-500"
                  }
                ]
              }
            },
            {
              "fieldLabel": "Budget",
              "fieldType": "dropdown",
              "fieldOptions": {
                "values": [
                  {
                    "option": "Under $1,000"
                  },
                  {
                    "option": "$5,000-$10,000"
                  },
                  {
                    "option": "$20,000+"
                  }
                ]
              }
            },
            {
              "fieldLabel": "Timeline",
              "fieldType": "dropdown",
              "fieldOptions": {
                "values": [
                  {
                    "option": "Just exploring"
                  },
                  {
                    "option": "1-3 months"
                  },
                  {
                    "option": "Within 30 days"
                  }
                ]
              }
            },
            {
              "fieldLabel": "What do you need help with?",
              "fieldType": "textarea"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.formTrigger",
      "typeVersion": 2.6,
      "position": [
        0,
        0
      ],
      "id": "73d2e427-14ba-4d75-88ad-33cb3391ce5e",
      "name": "On form submission",
      "webhookId": "4e097b62-0504-4dc0-81d3-4fef3daba485"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=You are a sales qualification assistant for an AI automation consultancy.\n\nScore this inbound lead from 0 to 100 on budget, urgency, company size and how well the request fits AI automation work. Then set priority to Hot (75+), Warm (40-74) or Cold (under 40).\n\nLead:\nName: {{ $json['Name'] }}\nCompany: {{ $json['Company'] }}\nCompany size: {{ $json['Company Size'] }}\nBudget: {{ $json['Budget'] }}\nTimeline: {{ $json['Timeline'] }}\nNeeds help with: {{ $json['What do you need help with?'] }}",
        "hasOutputParser": true,
        "batching": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.9,
      "position": [
        224,
        0
      ],
      "id": "b98bc37c-78f3-4ca2-83f0-88d755307960",
      "name": "Basic LLM Chain"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-5-mini"
        },
        "builtInTools": {},
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.3,
      "position": [
        112,
        208
      ],
      "id": "f759fb6e-0b61-4ae8-9236-8c2495c7421d",
      "name": "OpenAI Chat Model"
    },
    {
      "parameters": {
        "jsonSchemaExample": "{\n    \"lead_score\": 87,\n  \"priority\": \"Hot\",\n  \"intent\": \"Automate customer support\",\n  \"estimated_value\": \"$10,000-$20,000\",\n  \"reasoning\": \"Strong budget, short timeline and a clear automation requirement.\",\n  \"recommended_next_action\": \"Contact within 24 hours and arrange a discovery call.\"\n}"
      },
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.3,
      "position": [
        368,
        208
      ],
      "id": "01a06499-ea8f-4226-8998-fa4a1fa2b558",
      "name": "Structured Output Parser"
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 3
                },
                "conditions": [
                  {
                    "leftValue": "={{  $json.output.priority  }}",
                    "rightValue": "Hot",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "id": "a9d41ef2-2b85-4606-aeae-e9c35ae0751b"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "HOT"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 3
                },
                "conditions": [
                  {
                    "id": "90e69e90-4826-40a9-9ada-94b85ea6d0c1",
                    "leftValue": "={{ $json.output.priority }}",
                    "rightValue": "Warm",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "WARM"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 3
                },
                "conditions": [
                  {
                    "id": "ed50544e-c449-4723-a367-8b7200fa49a4",
                    "leftValue": "={{ $json.output.priority }}",
                    "rightValue": "Cold",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "COLD"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.4,
      "position": [
        592,
        0
      ],
      "id": "b9194ac6-7a7f-4bdd-a4aa-d46136eb42ca",
      "name": "Switch"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=Write a short, friendly reply email to this sales lead.\n\nPut the subject on the first line, prefixed \"Subject:\". Then two short paragraphs: acknowledge exactly what they asked for, and propose a 30 minute discovery call this week.\n\nTheir name: {{ $('On form submission').item.json['Name'] }}\nTheir company: {{ $('On form submission').item.json['Company'] }}\nWhat they need: {{ $('On form submission').item.json['What do you need help with?'] }}",
        "batching": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.9,
      "position": [
        816,
        -112
      ],
      "id": "80cda242-566e-4c4e-a7c8-1597133775c5",
      "name": "Write the reply email"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-5-mini"
        },
        "builtInTools": {},
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.3,
      "position": [
        816,
        32
      ],
      "id": "20239903-59d7-4dd9-94f4-db9212246504",
      "name": "OpenAI Chat Model1"
    },
    {
      "parameters": {
        "operation": "addToDate",
        "magnitude": "={{  $now  }}",
        "duration": 3,
        "outputFieldName": "follow_up_date",
        "options": {}
      },
      "type": "n8n-nodes-base.dateTime",
      "typeVersion": 2,
      "position": [
        960,
        176
      ],
      "id": "38e94545-2888-4c10-9147-e3cdcb43fc81",
      "name": "Set follow-up date"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "dbe1344b-58a1-4ee0-aac8-8fa4e13ed349",
              "name": "status",
              "value": "closed",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.5,
      "position": [
        960,
        352
      ],
      "id": "01dcb717-7cf7-4909-a832-a2d6add56673",
      "name": "Close the lead"
    },
    {
      "id": "4088af42-b65b-496c-a13e-8ad39f3ab2d2",
      "name": "Setup",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        -532
      ],
      "parameters": {
        "content": "## AI Lead Qualification - setup\nVideo: https://www.youtube.com/watch?v=9X0gUURGDwU\n\n1. Open **OpenAI Chat Model** and **OpenAI Chat Model1** and pick your OpenAI credential.\n2. Click **Execute workflow** and fill in the test form (name, company, email, company size, budget, timeline, what they need).\n3. The AI scores the lead 0-100 and the **Switch** routes it: Hot drafts a reply email, Warm sets a follow-up date 3 days out, Cold closes the lead.\n\nThe Hot branch only drafts the email text - connect Gmail or your CRM when you want it sent.",
        "height": 360,
        "width": 620,
        "color": 5
      }
    }
  ],
  "connections": {
    "On form submission": {
      "main": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Basic LLM Chain": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Write the reply email",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Set follow-up date",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Close the lead",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Write the reply email",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate"
  },
  "pinData": {}
}