DEV Community

Peter Park
Peter Park

Posted on

How to Build a Cold Email Scoring System with JavaScript

When building ColdMailAI, one of the core features I needed was a way to score cold emails before they go out. Not just grammar checking — but evaluating whether the email is actually likely to get a response.

Here's the scoring approach I landed on, broken down into code you can adapt for your own projects.

The Scoring Framework

A good cold email score should evaluate these dimensions:

  1. Length — shorter emails get more replies
  2. Personalization signals — does it reference something specific?
  3. Call-to-action clarity — is there exactly one clear ask?
  4. Spam trigger words — words that hurt deliverability
  5. Reading level — simpler language performs better

Implementation

1. Length Score

function scorelength(text) {
  const wordCount = text.split(/\s+/).length;

  if (wordCount <= 50) return 100;      // ideal
  if (wordCount <= 80) return 85;       // good
  if (wordCount <= 120) return 60;      // acceptable
  if (wordCount <= 200) return 30;      // too long
  return 10;                             // way too long
}
Enter fullscreen mode Exit fullscreen mode

The sweet spot for cold emails is 50-80 words. Anything over 120 words sees a significant drop in reply rates according to multiple industry analyses.

2. Personalization Detection

function scorePersonalization(text, recipientData) {
  let score = 0;
  const checks = [
    { pattern: recipientData?.company, weight: 20, label: 'company name' },
    { pattern: recipientData?.name, weight: 15, label: 'recipient name' },
    { pattern: recipientData?.role, weight: 15, label: 'role reference' },
    { pattern: /I (saw|noticed|read|heard|found)/i, weight: 20, label: 'research signal' },
    { pattern: /your (recent|latest|new)/i, weight: 15, label: 'timely reference' },
    { pattern: /(congratulations|congrats) on/i, weight: 15, label: 'milestone reference' }
  ];

  for (const check of checks) {
    if (!check.pattern) continue;
    const found = check.pattern instanceof RegExp 
      ? check.pattern.test(text) 
      : text.toLowerCase().includes(check.pattern.toLowerCase());
    if (found) score += check.weight;
  }

  return Math.min(score, 100);
}
Enter fullscreen mode Exit fullscreen mode

3. CTA Clarity

function scoreCTA(text) {
  const ctaPatterns = [
    /would (it|you) be (worth|open to|interested)/i,
    /can we (chat|talk|schedule|hop on)/i,
    /free for a (quick|brief|15[- ]min)/i,
    /want me to (send|share|show)/i,
    /reply (with|if|to let)/i,
    /let me know (if|when|whether)/i
  ];

  const ctaCount = ctaPatterns.filter(p => p.test(text)).length;

  if (ctaCount === 1) return 100;  // perfect - one clear CTA
  if (ctaCount === 0) return 20;   // no CTA at all
  if (ctaCount === 2) return 60;   // slightly diluted
  return 30;                        // too many asks
}
Enter fullscreen mode Exit fullscreen mode

4. Spam Word Detection

function scoreSpamRisk(text) {
  const spamWords = [
    'guaranteed', 'free trial', 'act now', 'limited time',
    'click here', 'buy now', 'no obligation', 'risk free',
    'as seen on', 'double your', 'earn extra', 'be your own boss',
    'million dollar', 'once in a lifetime', 'special promotion'
  ];

  const lowerText = text.toLowerCase();
  const hits = spamWords.filter(w => lowerText.includes(w));

  const penalty = hits.length * 20;
  return Math.max(100 - penalty, 0);
}
Enter fullscreen mode Exit fullscreen mode

5. Putting It Together

function scoreEmail(text, recipientData) {
  const scores = {
    length: scorelength(text),
    personalization: scorePersonalization(text, recipientData),
    cta: scoreCTA(text),
    spamRisk: scoreSpamRisk(text)
  };

  // Weighted average
  const weights = {
    length: 0.2,
    personalization: 0.35,
    cta: 0.25,
    spamRisk: 0.2
  };

  const total = Object.keys(scores).reduce((sum, key) => {
    return sum + (scores[key] * weights[key]);
  }, 0);

  return {
    overall: Math.round(total),
    breakdown: scores,
    suggestions: generateSuggestions(scores)
  };
}

function generateSuggestions(scores) {
  const suggestions = [];
  if (scores.length < 60) suggestions.push('Your email is too long. Try cutting it down to under 80 words.');
  if (scores.personalization < 40) suggestions.push('Add a specific reference to the recipient or their company.');
  if (scores.cta < 60) suggestions.push('Include exactly one clear call-to-action.');
  if (scores.spamRisk < 60) suggestions.push('Remove spam trigger words to improve deliverability.');
  return suggestions;
}
Enter fullscreen mode Exit fullscreen mode

Usage Example

const email = \`Hi Sarah,

I saw your talk at SaaStr about scaling outbound — the part about hiring SDRs before having a repeatable process really resonated.

We built a tool that helps teams write better cold emails by scoring them before they go out. Would it be worth a 15-min call to see if it could help your team?\`;

const result = scoreEmail(email, { 
  name: 'Sarah', 
  company: 'Acme Corp',
  role: 'VP Sales' 
});

console.log(result);
// { overall: 82, breakdown: { length: 85, personalization: 70, cta: 100, spamRisk: 100 }, suggestions: [] }
Enter fullscreen mode Exit fullscreen mode

What I'd Add Next

  • Subject line scoring — separate evaluation for the subject line
  • Reading level analysis — using Flesch-Kincaid or similar
  • A/B variant generator — automatically create variations to test
  • Industry benchmarks — compare scores against category averages

This is a simplified version of the scoring logic in ColdMailAI. The production version also takes into account the recipient's industry, the sender's domain reputation, and historical reply data.

If you're building anything in the email/outreach space, I'd love to hear how you approach scoring. Drop a comment below!

Top comments (0)