Bot scoring
You have spam scoring, I would like bot scoring too. I have implemetned myself, but you could probably do better: const botScore = calculateBotScore(user.emailStats); if(botScore>= 65) { return new Response(Bot score too high ${botScore}, { status: 403 }); } else if(now - previousInboundTime < 2000 || now - previousOutboundTime < 3000) { return new Response(Bot score too high (99), { status: 403 }); } You would need to keep stats on inbound and outbound emails and inbound/outbound sizes per email address for my approach. Because inbounds may not actually be a followup to outbounds the algorithm below may err to false negatives, false positive are unlikely due to timing. I have started with a threshold of 65 ... some very fast prolific emailers using cut-paste might get in the 75 range. function calculateBotScore(exchanges) { if (exchanges.length < 5) return 0; let totalSuspicion = 0; let validExchanges = 0; for (let i = 1; i < exchanges.length; i++) { const current = exchanges[i]; const previous = exchanges[i-1]; // Human's response time = current inbound time - previous outbound time const responseTimeMs = current.inboundTime - previous.outboundTime; // Skip invalid exchanges if (responseTimeMs <= 0) continue; validExchanges++; // Calculate minimum expected human response time // Human needs to read YOUR outbound message and type THEIR inbound response const outboundWords = previous.outboundBodySize / 5.5; // What human reads const inboundWords = current.inboundBodySize / 5.5; // What human types const readingTimeMs = (outboundWords / 200) 60 1000 * 1.3; // Reading + comprehension const typingTimeMs = (inboundWords / 35) 60 1000 * 1.2; // Typing + proofreading const minHumanTimeMs = Math.max(3000, readingTimeMs + typingTimeMs + 2000); // +2s thinking // Calculate suspicion for this exchange if (responseTimeMs < minHumanTimeMs) { const speedFactor = minHumanTimeMs / responseTimeMs; totalSuspicion += Math.min(100, speedFactor * 25); } } if (validExchanges === 0) return 0; // Average suspicion across all exchanges const avgSuspicion = totalSuspicion / validExchanges; // Bonus for consistency (bots tend to have similar response times) const responseTimes = []; for (let i = 1; i 0) responseTimes.push(responseTime); } if (responseTimes.length > 1) { const mean = responseTimes.reduce((a, b) => a + b) / responseTimes.length; const variance = responseTimes.reduce((acc, rt) => acc + Math.pow(rt - mean, 2), 0) / responseTimes.length; const coefficientOfVariation = Math.sqrt(variance) / mean; // Low variation = more bot-like const consistencyBonus = coefficientOfVariation < 0.3 ? 15 : 0; return Math.min(100, Math.round(avgSuspicion + consistencyBonus)); } return Math.min(100, Math.round(avgSuspicion)); }

More in Feature
- Server-Side TemplatesVotes 1
- Roles for team membersVotes 1
- Export messages to CSVVotes 1
- Domain-Level Team Member AccessVotes 1
- webhook-id on Route FormVotes 1
