Skip to main content

Spam Detection

Detect spam comments in your discussions.

Every comment gets one of three outcomes:

OutcomeResponseWhat to do
Spamis_spam is trueDelete it.
Suspected spamis_spam is false, suspected_spam is true, suggestion is filled inSend it back to the commenter with the suggestion, as you would a comment that needs revision. A real person can fix it and post again; a spammer won't bother.
Not spamis_spam and suspected_spam are both falsePublish it as normal.

What it detects:

  • Promotional/advertising content
  • Bot-generated text patterns
  • Link spam and SEO manipulation
  • Repeated/duplicate comments
  • Off-topic noise

Reference​

See the Spam Detection API Reference for method signatures and parameters.

Response: SpamDetectionResult

By Example​

Basic Usage​

// With article context (more accurate)
const result = await client.checkSpam(
"Buy cheap watches at example.com!",
articleId
);

// Without context (standalone check)
const result2 = await client.checkSpam("Buy cheap watches at example.com!");

console.log(`Is spam: ${result.is_spam}`);
console.log(`Confidence: ${result.confidence.toFixed(2)}`);
console.log(`Reasoning: ${result.reasoning}`);

if (result.is_spam) {
// Delete it
} else if (result.suspected_spam) {
// Send it back to the commenter with result.suggestion
} else {
// Publish it
}

First-Pass Screening​

Spam is decided by a fast first-pass screen alone. No comment is sent for a fuller assessment of spam: spam needs a verdict, not an explanation. The screen gives each comment a probability of being spam, and that decides the outcome:

  • 0.85 or above, spam: is_spam is true, confidence is the screen's probability, and reasoning is "Classified as spam by first-pass screening." The cutoff is set high so that real comments are not deleted.
  • 0.50 up to 0.85, suspected spam: is_spam is false, suspected_spam is true, and suggestion holds a short message for the commenter. confidence is the confidence that it is not spam, and reasoning is empty.
  • Below 0.50, not spam: is_spam and suspected_spam are false, confidence is the confidence that it is not spam, and reasoning and suggestion are empty, since there is nothing to explain.

The suggestion for a suspected-spam comment is one of two:

  • If the comment contains a link: "This looks like spam. How about removing the link?"
  • Otherwise: "This reads like promotion. How about saying what you think about the discussion?"

If screening is unavailable, the comment is let through rather than deleted without a verdict: is_spam is false, confidence is 0, and reasoning is "Not checked for spam: screening was unavailable." A check that was not screened is not charged.

In a megacall, a comment answered as spam ends the request: every other check is returned as null and only the spam check is charged. A suspected-spam comment is not spam, so the other checks still run and are returned as usual.

Best Practices​

  • Use article context when available for better accuracy.
  • Act on the outcome, not the confidence. Respectify has already applied the thresholds: delete when is_spam is true, send the comment back when suspected_spam is true, and publish otherwise.
  • Show the suggestion to the writer of a suspected-spam comment, alongside any other feedback for the comment (for example from comment health), so they can fix it and post again.
  • Log false positives to understand patterns.