Jev Academy

Project lab

Newsletter triage (conceptual)

Like sorting mail over a bin. One call asks three things: is it urgent (Noul), what is it about (Choice), and should you keep it (Noul). Example theme only.

curl

bash
curl -X POST https://api.typesafe.ai/v1/systemone \
  -H "Authorization: Bearer $TYPESAFE_API_KEY" \
  -H "Content-Type: application/json" \
  -d @- <<'EOF'
{
  "state": {
    "from": "alerts@example.com",
    "subject": "Your invoice is past due — action required today",
    "snippet": "Account balance overdue. Click to pay before services pause."
  },
  "model": "jev-latest",
  "questions": {
    "topic": {
      "type": "choice",
      "instructions": "Newsletter / inbox topic",
      "criteria": {
        "billing": "Invoices, payments, receipts",
        "product": "Feature or product updates",
        "promo": "Marketing or promotions",
        "other": "Other"
      }
    },
    "is_urgent": {
      "type": "noul",
      "instructions": "Is this time-sensitive for the recipient?"
    },
    "keep": {
      "type": "noul",
      "instructions": "Should this stay in the primary inbox?"
    }
  }
}
EOF

JavaScript

js
const key = process.env.TYPESAFE_API_KEY;
if (!key) throw new Error("TYPESAFE_API_KEY is not set");

const res = await fetch("https://api.typesafe.ai/v1/systemone", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${key}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    state: {
      from: "alerts@example.com",
      subject: "Your invoice is past due — action required today",
      snippet: "Account balance overdue. Click to pay before services pause.",
    },
    model: "jev-latest",
    questions: {
      topic: {
        type: "choice",
        instructions: "Newsletter / inbox topic",
        criteria: {
          billing: "Invoices, payments, receipts",
          product: "Feature or product updates",
          promo: "Marketing or promotions",
          other: "Other",
        },
      },
      is_urgent: {
        type: "noul",
        instructions: "Is this time-sensitive for the recipient?",
      },
      keep: {
        type: "noul",
        instructions: "Should this stay in the primary inbox?",
      },
    },
  }),
});

if (!res.ok) throw new Error(`HTTP ${res.status}`);
const { answers } = await res.json();
console.log({
  topic: answers.topic.choice,
  urgent: answers.is_urgent.noul,
  keep: answers.keep.noul,
});

Notes

  • This is a concept lab. Do not connect it to live newsletter repos.
  • After you read the three answers, your code applies the keep or archive rules.

Sources

← All labsBrowse use cases →