jevrecipes

Recipe catalog / spam-signal

Detect spam content

spam-signal is a Jev recipe from the jev-recipes TypeScript package. Is message unsolicited promotional, scam, or bulk content rather than a genuine contribution? Use it when you need a yes/no gate before publishing, forwarding, or replying to community posts, comments, or inbound messages.

Last updated .

Explore this recipe interactively · Source and implementation guide · Markdown version

How do I use spam-signal in TypeScript?

Install with npm install jev-recipes. Requires Node.js 22.9 or newer and ES modules. Set TYPESAFE_API_KEY in your server environment for live calls, which send input to TypeSafe and use API quota. See the installation guide.

import { spamSignal } from 'jev-recipes/spam-signal';

const result = await spamSignal({
  "message": "Congratulations!! You have been selected for a $500 gift card. Claim now at bit.ly/claim-prize-4421 before it expires tonight!!!",
  "context": "Reply posted in a community forum thread about troubleshooting a printer driver.",
  "minConfidence": 0.8
});
console.log(result);

What input does spam-signal take?

FieldTypeNeeded
messagestringRequired
contextstringOptional
minConfidencenumberOptional
Full input and result schemas
{
  "input": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "message": {
        "type": "string"
      },
      "context": {
        "type": "string"
      },
      "minConfidence": {
        "type": "number",
        "minimum": 0,
        "maximum": 1
      }
    },
    "required": [
      "message"
    ]
  },
  "result": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "model": {
        "type": "string"
      },
      "usage": {
        "type": "object",
        "properties": {
          "input_tokens": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "output_tokens": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          }
        },
        "required": [
          "input_tokens",
          "output_tokens"
        ],
        "additionalProperties": false
      },
      "status": {
        "type": "string",
        "enum": [
          "ready",
          "review"
        ]
      },
      "probability": {
        "type": "number",
        "minimum": 0,
        "maximum": 1
      },
      "confidence": {
        "type": "number",
        "minimum": 0,
        "maximum": 1
      },
      "verdict": {
        "type": "string",
        "enum": [
          "spam",
          "genuine"
        ]
      }
    },
    "required": [
      "model",
      "usage",
      "status",
      "probability",
      "confidence",
      "verdict"
    ],
    "additionalProperties": false
  }
}

What does a spam-signal result look like?

This hand-authored response demonstrates the contract. It is not a model accuracy measurement. Run it without an API key: npx jev-recipes demo spam-signal.

{
  "model": "demo-fixture",
  "usage": {
    "input_tokens": 0,
    "output_tokens": 0
  },
  "status": "ready",
  "probability": 0.97,
  "confidence": 0.97,
  "verdict": "spam"
}

Input

See shared options and behavior for client configuration, validation, and errors. Types are inferred from this folder's Zod 4 schemas. context is optional and is omitted from the request when absent.

Result

verdict is spam when Jev's yes probability is at least 0.5 and genuine otherwise. probability is that yes probability. confidence is the probability of the chosen side, so a 0.1 yes probability yields genuine with 0.9 confidence.

A result is ready when confidence meets minConfidence. Otherwise it is review. Treat a review result as unknown and fall back to your safe default, such as holding the message for a moderator.

Reuse and calls

Uses the shared gate helper, a single yes/no question. This folder owns the question wording, the outcome descriptions, and the review policy. A live invocation makes one logical Jev request.

Limits

The recipe judges the wording of one message. It does not know the sender's history, how many times similar text was posted, or what a shortened link resolves to, so pair it with rate limits and link checks. Supply context to describe the venue and its rules; an on-topic product recommendation in a thread asking for suggestions is genuine, while the same text dropped into an unrelated thread leans spam. Removal, hiding, and appeal decisions belong in application code.

Example input

demo.json contains editable input and a hand-authored response. After installing jev-recipes, npx jev-recipes demo spam-signal shows an offline illustration, not an accuracy measurement. Use npx jev-recipes describe spam-signal to inspect the input and result schemas.

How accurate is spam-signal?

Fixture only

No verified live accuracy measurement is available. Evaluate representative cases before using this decision in your workflow.

Use the evaluation guide to measure this decision on your own labeled cases.

What are the limits of spam-signal?