AutomationFlowsAI & RAG › Wf-009 Hot Lead Alert

Wf-009 Hot Lead Alert

WF-009 Hot Lead Alert. Uses supabase, emailSend. Webhook trigger; 7 nodes.

Webhook trigger★★★★☆ complexity7 nodesSupabaseEmail Send
AI & RAG Trigger: Webhook Nodes: 7 Complexity: ★★★★☆ Added:

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "name": "WF-009 Hot Lead Alert",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "hot-lead-alert",
        "responseMode": "onReceived",
        "responseData": "allEntries",
        "options": {}
      },
      "id": "wf009-node-1",
      "name": "Webhook Trigger",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "operation": "getAll",
        "tableId": "notification_preferences",
        "returnAll": true,
        "filterType": "string",
        "filterString": "=tenant_id=eq.{{ $json.body.tenant_id }}"
      },
      "id": "wf009-node-2",
      "name": "Get Notification Preferences",
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        500,
        300
      ],
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "getAll",
        "tableId": "users",
        "returnAll": true,
        "filterType": "string",
        "filterString": "=tenant_id=eq.{{ $('Webhook Trigger').item.json.body.tenant_id }}&role=in.(owner,admin)"
      },
      "id": "wf009-node-3",
      "name": "Get Owner and Admin Users",
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        750,
        300
      ],
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// Build email recipient list from owner/admin users and notification preferences\nconst webhookData = $('Webhook Trigger').first().json.body;\nconst notifPrefs = $('Get Notification Preferences').all();\nconst users = $('Get Owner and Admin Users').all();\n\n// Get notification preferences keyed by user_id\nconst prefsMap = {};\nfor (const pref of notifPrefs) {\n  prefsMap[pref.json.user_id] = pref.json;\n}\n\n// Build recipient list: include users who have hot_lead notifications enabled\n// or include all owner/admin users if no specific preference is set\nconst recipients = [];\nfor (const user of users) {\n  const userId = user.json.id;\n  const prefs = prefsMap[userId];\n  \n  // Include user if:\n  // 1. No notification prefs exist (default to enabled)\n  // 2. hot_lead_email preference is true\n  // 3. email_notifications is generally enabled\n  const shouldNotify = !prefs \n    || prefs.hot_lead_email !== false \n    || prefs.email_notifications !== false;\n  \n  if (shouldNotify && user.json.email) {\n    recipients.push({\n      user_id: userId,\n      email: user.json.email,\n      full_name: user.json.full_name || user.json.email,\n      role: user.json.role\n    });\n  }\n}\n\n// Build comma-separated email list for the email node\nconst emailList = recipients.map(r => r.email).join(', ');\n\nreturn {\n  json: {\n    recipients: recipients,\n    emailList: emailList,\n    recipientCount: recipients.length,\n    caller_name: webhookData.caller_name,\n    caller_number: webhookData.caller_number,\n    call_id: webhookData.call_id,\n    summary: webhookData.summary,\n    tenant_id: webhookData.tenant_id\n  }\n};"
      },
      "id": "wf009-node-4",
      "name": "Build Recipient List",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1000,
        300
      ]
    },
    {
      "parameters": {
        "fromEmail": "TitleFlow AI <user@example.com>",
        "toEmail": "={{ $json.emailList }}",
        "subject": "=\ud83d\udd25 Hot Lead: {{ $json.caller_name }}",
        "emailType": "html",
        "html": "=<!DOCTYPE html>\n<html>\n<head>\n  <meta charset=\"utf-8\">\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n  <title>Hot Lead Alert</title>\n</head>\n<body style=\"margin:0; padding:0; background-color:#000000; font-family:'Inter', 'Manrope', Arial, sans-serif;\">\n  <table role=\"presentation\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" style=\"background-color:#000000;\">\n    <tr>\n      <td align=\"center\" style=\"padding:40px 20px;\">\n        <table role=\"presentation\" width=\"600\" cellpadding=\"0\" cellspacing=\"0\" style=\"background: linear-gradient(135deg, rgba(0,128,255,0.1), rgba(79,26,214,0.1)); border:1px solid rgba(255,255,255,0.1); border-radius:24px; overflow:hidden;\">\n          <!-- Header -->\n          <tr>\n            <td style=\"padding:40px 40px 20px; text-align:center;\">\n              <div style=\"display:inline-block; background:rgba(255,149,0,0.15); border:1px solid rgba(255,149,0,0.3); border-radius:12px; padding:8px 20px; margin-bottom:16px;\">\n                <span style=\"color:#FF9500; font-size:14px; font-weight:600;\">\ud83d\udd25 HOT LEAD DETECTED</span>\n              </div>\n              <h1 style=\"color:#FFFFFF; font-size:24px; font-weight:700; margin:16px 0 0;\">{{ $json.caller_name }}</h1>\n              <p style=\"color:rgba(255,255,255,0.5); font-size:14px; margin:8px 0 0;\">{{ $json.caller_number }}</p>\n              <div style=\"width:60px; height:4px; background:linear-gradient(90deg,#FF9500,#FF3B30); border-radius:2px; margin:16px auto 0;\"></div>\n            </td>\n          </tr>\n          <!-- Call Details -->\n          <tr>\n            <td style=\"padding:20px 40px;\">\n              <table role=\"presentation\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" style=\"background:rgba(255,255,255,0.05); border:1px solid rgba(255,255,255,0.1); border-radius:16px;\">\n                <tr>\n                  <td style=\"padding:20px;\">\n                    <p style=\"color:rgba(255,255,255,0.5); font-size:12px; font-weight:600; text-transform:uppercase; letter-spacing:1px; margin:0 0 8px;\">Call ID</p>\n                    <p style=\"color:#FFFFFF; font-size:14px; font-family:monospace; margin:0 0 16px;\">{{ $json.call_id }}</p>\n                    <p style=\"color:rgba(255,255,255,0.5); font-size:12px; font-weight:600; text-transform:uppercase; letter-spacing:1px; margin:0 0 8px;\">Call Summary</p>\n                    <p style=\"color:rgba(255,255,255,0.9); font-size:15px; line-height:1.6; margin:0;\">{{ $json.summary }}</p>\n                  </td>\n                </tr>\n              </table>\n            </td>\n          </tr>\n          <!-- CTA -->\n          <tr>\n            <td style=\"padding:16px 40px 32px; text-align:center;\">\n              <a href=\"https://titleflowai.ai/dashboard/calls/{{ $json.call_id }}\" style=\"display:inline-block; background:linear-gradient(135deg,#FF9500,#FF3B30); color:#FFFFFF; text-decoration:none; font-size:16px; font-weight:600; padding:14px 40px; border-radius:9999px;\">View Call Details</a>\n              <p style=\"color:rgba(255,255,255,0.4); font-size:13px; margin:16px 0 0;\">Respond quickly to maximize conversion.</p>\n            </td>\n          </tr>\n          <!-- Footer -->\n          <tr>\n            <td style=\"padding:24px 40px; border-top:1px solid rgba(255,255,255,0.1);\">\n              <p style=\"color:rgba(255,255,255,0.4); font-size:13px; line-height:1.5; margin:0; text-align:center;\">\n                TitleFlow AI &mdash; AI-Powered Voice Intelligence for Title Companies<br>\n                Sent to {{ $json.recipientCount }} team member(s) based on notification preferences.\n              </p>\n            </td>\n          </tr>\n        </table>\n      </td>\n    </tr>\n  </table>\n</body>\n</html>",
        "options": {}
      },
      "id": "wf009-node-5",
      "name": "Send Hot Lead Email",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 2.1,
      "position": [
        1250,
        300
      ],
      "credentials": {
        "smtp": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// Create a notification item for each recipient (owner/admin user)\nconst data = $('Build Recipient List').first().json;\nconst recipients = data.recipients;\nconst items = [];\n\nfor (const recipient of recipients) {\n  items.push({\n    json: {\n      user_id: recipient.user_id,\n      tenant_id: data.tenant_id,\n      type: 'hot_lead',\n      title: `Hot Lead: ${data.caller_name}`,\n      message: `Hot lead detected from ${data.caller_name} (${data.caller_number}). ${data.summary}`,\n      is_read: false,\n      metadata: JSON.stringify({\n        call_id: data.call_id,\n        caller_name: data.caller_name,\n        caller_number: data.caller_number\n      })\n    }\n  });\n}\n\nreturn items;"
      },
      "id": "wf009-node-6a",
      "name": "Prepare Notification Items",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1500,
        300
      ]
    },
    {
      "parameters": {
        "operation": "create",
        "tableId": "notifications",
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldName": "user_id",
              "fieldValue": "={{ $json.user_id }}"
            },
            {
              "fieldName": "tenant_id",
              "fieldValue": "={{ $json.tenant_id }}"
            },
            {
              "fieldName": "type",
              "fieldValue": "={{ $json.type }}"
            },
            {
              "fieldName": "title",
              "fieldValue": "={{ $json.title }}"
            },
            {
              "fieldName": "message",
              "fieldValue": "={{ $json.message }}"
            },
            {
              "fieldName": "is_read",
              "fieldValue": "={{ $json.is_read }}"
            }
          ]
        }
      },
      "id": "wf009-node-6b",
      "name": "Insert Notifications",
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        1750,
        300
      ],
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Webhook Trigger": {
      "main": [
        [
          {
            "node": "Get Notification Preferences",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Notification Preferences": {
      "main": [
        [
          {
            "node": "Get Owner and Admin Users",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Owner and Admin Users": {
      "main": [
        [
          {
            "node": "Build Recipient List",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Recipient List": {
      "main": [
        [
          {
            "node": "Send Hot Lead Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Hot Lead Email": {
      "main": [
        [
          {
            "node": "Prepare Notification Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Notification Items": {
      "main": [
        [
          {
            "node": "Insert Notifications",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "saveManualExecutions": true,
    "callerPolicy": "workflowsFromSameOwner"
  },
  "versionId": "wf009-v1",
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "tags": [
    {
      "name": "leads"
    },
    {
      "name": "alerts"
    },
    {
      "name": "email"
    }
  ]
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

WF-009 Hot Lead Alert. Uses supabase, emailSend. Webhook trigger; 7 nodes.

Source: https://github.com/rafiulislam4246/voice-sdr-title-agent/blob/main/app/n8n-workflows/WF-009-hot-lead-alert.json — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

Ai Assistant Agent Full Workflow. Uses supabase, httpRequest, emailSend. Webhook trigger; 18 nodes.

Supabase, HTTP Request, Email Send
AI & RAG

WF-007 Failed Payment Handler. Uses supabase, emailSend. Webhook trigger; 4 nodes.

Supabase, Email Send
AI & RAG

WF-006 Welcome Email. Uses emailSend, supabase. Webhook trigger; 3 nodes.

Email Send, Supabase
AI & RAG

Invoice Agent. Uses httpRequest, emailSend. Webhook trigger; 29 nodes.

HTTP Request, Email Send
AI & RAG

Template Overview This n8n workflow provides an intelligent, timezone-aware AI voice calling system for e-commerce businesses to automatically confirm customer orders via phone calls. The system uses

HTTP Request, Airtable, Schedule +1