safety · basic
Spam Detection
Screen contact-form messages for unsolicited generic promotion while keeping an explicit unclear route.
choicenoul
When to use it
- Contact forms
- Inbox triage
- Community intake
Example state
{
"message": "We guarantee page-one rankings. Buy 10,000 backlinks today. Reply for our price list.",
"source": "contact_form"
}Decision questions
choicemessage_type
Choose the best route for this inbound message.
sales— A potential customer evaluating our productpartnership— A concrete collaboration proposalsupport— An existing customer seeking helpspam— Unsolicited generic promotionunclear— Purpose is unclear
noulunsolicited_promotion
Is this message primarily unsolicited generic promotion rather than a relevant request?
Expected structured output
A route plus a spam probability that can be thresholded conservatively.
TypeScript example
import { choice, noul, TypeSafeClient } from "@typesafe-ai/sdk";
const client = new TypeSafeClient();
const result = await client.systemOne({
state: {
message:
"We guarantee page-one rankings. Buy 10,000 backlinks today. Reply for our price list.",
source: "contact_form",
},
questions: {
message_type: choice("Choose the best route for this inbound message.", {
sales: "A potential customer evaluating our product",
partnership: "A concrete collaboration proposal",
support: "An existing customer seeking help",
spam: "Unsolicited generic promotion",
unclear: "Purpose is unclear",
}),
unsolicited_promotion: noul(
"Is this message primarily unsolicited generic promotion rather than a relevant request?"
),
},
});Why this design works
- An unclear route avoids forcing ambiguous messages into spam.
- A separate probability lets the application choose a conservative threshold.
Limits and boundaries
- Do not automatically delete low-confidence messages.
- This is a semantic triage pattern, not a full anti-abuse system.
Sources and inspiration
Continue
Browse all templates, learn the official SDK shape, or estimate production volume with the cost calculator.