example · ghost

06 / 06

Ghost spam filter.

Updated May 12, 2026

A webhook-style worker for scoring Ghost member signup notes, comment text, or custom form payloads before you accept them downstream.

javascript
// Generic Ghost webhook receiver. Adapt the field mapping to your event.
export default {
  async fetch(req, env) {
    if (req.method !== "POST") return new Response("method", { status: 405 });
    const event = await req.json();

    const text = [
      event.member?.name,
      event.member?.email,
      event.comment?.html,
      event.message,
    ].filter(Boolean).join("\n");

    let probability = 0;
    const resp = await fetch("https://api.siftfy.io/v1/predict", {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        "X-API-Key": env.SIFTFY_KEY,
      },
      body: JSON.stringify({ text }),
    });
    if (resp.ok) probability = (await resp.json()).spam_probability;

    if (probability >= 0.85) return new Response("ok", { status: 200 });
    await env.CLEAN_QUEUE.send({ event, probability });
    return new Response("ok", { status: 200 });
  },
};

Production notes

  1. 01Ghost event payloads differ by feature and plugin; map the text fields you actually collect.
  2. 02Classify user-generated text, not just email addresses.
  3. 03For member signup fraud, combine Siftfy with email validation and rate limits.

Common questions

How do I add spam filtering to a Ghost site?

Create a Ghost custom integration with a webhook that posts events to a small worker. The worker concatenates the user-generated text fields, calls Siftfy, and only forwards clean events to your downstream queue or notifier. The full worker is shown above.

Which Ghost fields should I send to Siftfy?

Send the human-written text you actually care about: comment HTML, member signup notes, custom form `message` fields. Don't send only the email address — Siftfy is a text classifier, not an email-reputation service.

Can this handle Ghost comment moderation too?

Yes. Map `event.comment?.html` into the concatenated text, then push high-probability comments to a moderation queue you check daily. Combine with Ghost's built-in member-only commenting for a strong baseline.

How do I stop fake Ghost member signups?

Score the signup `note` and email-domain together, rate-limit by IP, and require email verification. For domains seen abusing signups, add them to a denylist so the worker rejects them before calling Siftfy.

Get a free API key

More patterns: all examples, contact forms, API reference.