Home30How to Build AI Lead Scoring…
30

How to Build AI Lead Scoring with Salesforce, GPT-4o, and Slack in n8n

How to Build AI Lead Scoring with Salesforce, GPT-4o, and Slack in n8n

How to Build AI Lead Scoring with Salesforce, GPT-4o, and Slack in n8n

Your sales team is drowning in leads. Last week you got 247. Yesterday alone, 58. But here’s the real problem: they’re spending three hours manually qualifying each batch, leaving scores written in messy spreadsheets, and the best leads get worked last because nobody marked them as priority. By then, they’ve already gone cold.

What if your AI could instantly score every lead the moment it enters Salesforce? Not just a random 1-100 number, but a real assessment: Is this a hot prospect ready to buy? A warm lead worth nurturing? Or cold?

That’s exactly what we’re building today. In this guide, you’ll create a complete AI-powered lead-scoring workflow in n8n that connects Salesforce, GPT-4o, and Slack. You’ll master data masking—a privacy-first technique that keeps PII out of the AI’s hands. And you’ll have a system that runs automatically, scoring leads while your team sleeps.

Ready to skip the manual building and import a production-ready template? We’ve pre-built this entire workflow. Grab the template and get started in under 5 minutes.

What You’ll Build

By the end of this guide, you’ll have a fully automated lead-scoring system that:

  1. Triggers instantly when a new lead lands in Salesforce, no manual intervention needed
  2. Masks sensitive data (names, emails, phone numbers) before it ever leaves your system, keeping PII private
  3. Scores each lead with GPT-4o, assigning a score (1-100), tier (Hot/Warm/Cold), and actionable next steps
  4. Restores original data after scoring, so your Slack message has the real contact info intact
  5. Posts to Slack with a clean, formatted notification that your sales team acts on immediately

How It Works — The Big Picture

Before we dig into the code, let’s see how the pieces fit together:

┌──────────────┐         ┌──────────────┐         ┌──────────────┐
│ 1. SALESFORCE│         │ 2. LOOP/      │         │ 3. FETCH     │
│ TRIGGER      │────────▶│    SPLIT      │────────▶│ LEAD DETAILS │
│              │         │  (splitIn5s)  │         │ (HTTP Request)
└──────────────┘         └──────────────┘         └──────────────┘
        │                        │                        │
        │                        │                        │
        │                        └────────────────────────┘
        │                                  │
        │                    ┌─────────────▼──────────────┐
        │                    │ 4. MASK SENSITIVE DATA     │
        │                    │ (Code node)                │
        │                    │ Strip email, phone, name   │
        │                    │ Store mapping: real→masked │
        │                    └─────────────┬──────────────┘
        │                                  │
        │                    ┌─────────────▼──────────────┐
        │                    │ 5. AI LEAD SCORING         │
        │                    │ (OpenAI GPT-4o)            │
        │                    │ Analyze masked lead        │
        │                    │ Score, tier, reasoning     │
        │                    └─────────────┬──────────────┘
        │                                  │
        │                    ┌─────────────▼──────────────┐
        │                    │ 6. UNMASK LEAD DATA        │
        │                    │ (Code node)                │
        │                    │ Restore email, phone, name │
        │                    │ From mapping: masked→real  │
        │                    └─────────────┬──────────────┘
        │                                  │
        │                    ┌─────────────▼──────────────┐
        │                    │ 7. POST TO SLACK           │
        │                    │ Format and send            │
        │                    │ scored lead notification   │
        │                    │ to sales channel           │
        │                    └────────────────────────────┘

The key innovation here is Steps 4 and 6: data masking and unmasking. Your lead’s real email and phone number never get sent to OpenAI. Instead, GPT-4o analyzes a sanitized version, then we restore the original data before Slack posts it. Privacy by design.