{
  "name": "Demo-Workflow",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "lead-qualifier-demo",
        "responseMode": "responseNode",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        0,
        0
      ],
      "id": "c334fb39-6928-4f8d-b3c0-9dd55335515d",
      "name": "Webhook",
      "webhookId": "53dfdee6-0d17-474f-802c-9b88376033a8"
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-4o-mini",
          "mode": "list",
          "cachedResultName": "GPT-4O-MINI"
        },
        "responses": {
          "values": [
            {
              "role": "system",
              "content": "You are a lead-qualification assistant for a service business. You receive one inbound lead message and return ONLY a valid JSON object (no prose, no markdown) with exactly this shape:\n\n{\n  \"score\": \"Hot\" | \"Warm\" | \"Cold\",\n  \"reasoning\": \"one or two sentences explaining the score\",\n  \"extracted\": {\n    \"intent\": \"what the lead wants\",\n    \"urgency\": \"High\" | \"Medium\" | \"Low\",\n    \"budget_signal\": \"any hint of budget or 'none'\",\n    \"timeline\": \"when they need it or 'unspecified'\"\n  },\n  \"suggested_reply\": \"a warm, professional, personalized reply of 2-4 sentences the business owner can send as-is. Address them by name if provided. Acknowledge their situation, answer their question, and propose a clear next step.\"\n}\n\nRules: Hot = urgent + clear intent to buy soon. Warm = interested but not urgent. Cold = vague, tire-kicker, or spam. Never invent facts not in the message. Output JSON only."
            },
            {
              "content": "=Lead name: {{ $json.body.name }}\nEmail: {{ $json.body.email }}\nMessage: {{ $json.body.message }}"
            }
          ]
        },
        "builtInTools": {},
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 2.1,
      "position": [
        176,
        0
      ],
      "id": "febe56fc-403d-4518-9009-8d4f979993ff",
      "name": "Message a model",
      "credentials": {
        "openAiApi": {
          "id": "tAbhBgnUVm0wwV9i",
          "name": "sales.quickkShip"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "const out = $input.first().json;\n// The OpenAI node's output shape varies by n8n version.\n// Newest (Responses API): { output: [ { content: [ { type: 'output_text', text: '...' } ] } ] }\n// Older versions: message.content / content / text / response.\nlet raw =\n  out.output?.[0]?.content?.find?.(c => c.type === 'output_text')?.text ??\n  out.output?.[0]?.content?.[0]?.text ??\n  out.message?.content ??\n  out.content ??\n  out.text ??\n  out.response ??\n  out;\nif (Array.isArray(raw)) raw = raw.find(c => c.type === 'output_text')?.text ?? raw[0]?.text ?? raw;\nlet data = {};\ntry {\n  data = typeof raw === 'string'\n    ? JSON.parse(raw.replace(/^```(?:json)?\\s*|\\s*```$/g, ''))\n    : (raw ?? {});\n} catch (e) { data = {}; }\nreturn [{ json: {\n  ok: true,\n  score: data.score ?? null,\n  reasoning: data.reasoning ?? '',\n  extracted: data.extracted ?? {},\n  suggested_reply: data.suggested_reply ?? ''\n}}];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        464,
        0
      ],
      "id": "e9b1c3a4-8c79-4916-b0d7-09b06e534508",
      "name": "Code in JavaScript"
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ $json }}",
        "options": {}
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.5,
      "position": [
        672,
        0
      ],
      "id": "cf9ec9ea-4d3e-486c-8cb2-5b3227af89a8",
      "name": "Respond to Webhook"
    }
  ],
  "pinData": {},
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Message a model",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Message a model": {
      "main": [
        [
          {
            "node": "Code in JavaScript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate",
    "availableInMCP": true,
    "timeSavedMode": "fixed",
    "callerPolicy": "workflowsFromSameOwner",
    "executionTimeout": -1,
    "saveDataSuccessExecution": "all",
    "saveDataErrorExecution": "all"
  },
  "versionId": "c72c4383-5604-4fba-9aaf-3988eab12f09",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "8b54aba511b936e0fee752dc686c9054629ebfc698cbdae915bcbd21a339229e"
  },
  "id": "7YcQk0OZa2_Ld0fbeYFrv",
  "tags": []
}