Classify

Getting started

Read the Botpoison Classify docs page "Getting started" at https://botpoison.com/documentation/classify/getting-started.md
and use it to make this change in my project.
Use the stack this project already runs on, and ask me for my keys rather than inventing them.

Classify a submission in two steps. Your server sends the form, and Classify returns a verdict: a label and a score. It reads the content, so it works on any text a person types: contact forms, comments, signups and support email.

01Send the submission from your server

After the form reaches your server, send it to /classify with your secret key. Send the whole form for the best verdict, or a string for a single message box. Keep the secret key on your server, never in the browser.

npm install @botpoison/node
JavaScript
// 1. Import the library
import Botpoison from "@botpoison/node";
// or const Botpoison = require("@botpoison/node")
// 2. Create a new instance with your secret key, read from your server's
// environment: BOTPOISON_CLASSIFY_SECRET_KEY=sk_xxxxxxxx
const botpoison = new Botpoison({
secretKey: process.env.BOTPOISON_CLASSIFY_SECRET_KEY
});
server.post("/contact", async (req, res) => {
// 3. Classify the whole form and read the label
const { label } = await botpoison.classify(req.body, {
model: "standard",
timeout: 8000,
});
if (label === "spam") {
// Drop it, or file it away
return res.status(202).end();
}
// ...
});

In Node.js, classify() needs @botpoison/node 0.2.0 or later. Its options, its errors and a version without the library are in the @botpoison/node reference. Every other language posts to the REST API.

02Read the result

JSON
{
"label": "clean",
"score": 0.04,
"model": "standard-2026-10-10"
}
  • SpamDrop it, or file it away.
  • CleanDeliver it as usual.

Act on label. It is Botpoison's recommended cut on the score, spam from 0.8, so the two never disagree. To hold borderline messages for a person, or to draw your own line, use score. See Labels and scores.

Test key

Send the secret key test to try every path without real spam. Content containing botpoison-test-spam returns spam, botpoison-test-review returns clean with a score of 0.6, and botpoison-test-unavailable returns a 503. Test calls never count toward your plan. See Classify test mode.