The Better Thread

Ways to add coaching

WordPress plugin for native comments. Node.js SDK with the drop-in widget or your own UI. Or call the HTTP API directly. Your comments stay on your site. The secret key never reaches the browser.

Pick an integration

Each option is a full path. Follow the one that matches your site.

WordPress plugin

Native comments, no custom backend. Install the plugin, paste your API key, and coach writers on the form.

WordPress setup →

SDK + widget

A small score route on your server, plus the drop-in coaching UI on your existing comment form.

SDK + widget setup →

SDK + custom UI

Same Node.js SDK, your own coaching surface. Call your score route and render the JSON yourself.

SDK + custom UI setup →

HTTP API

Call the same four /v1 operations directly from your server. Score drafts and keep the originality index in sync.

HTTP API setup →

Option 1

WordPress plugin

For sites that use WordPress native comments. The plugin wraps the coaching widget and talks to the API for you — no Node.js score route.

Install from the WordPress plugin directory

  1. In wp-admin, open Plugins → Add New.
  2. Search for The Better Thread.
  3. Click Install Now, then Activate.

Plugin page: wordpress.org/plugins/thebetterthread/.

Or download the ZIP

  1. Download the latest plugin ZIP.
  2. In wp-admin, open Plugins → Add New → Upload Plugin.
  3. Choose the ZIP, click Install Now, then Activate.

Or install from source (local development)

For a local WordPress install, copy the plugin into your plugins folder and activate it there.

  1. Clone or download the plugin source.
  2. Copy the plugin directory into wp-content/plugins/thebetterthread/ on your local site (or symlink it there while you develop).
  3. In wp-admin, open Plugins, find The Better Thread, and click Activate.
# From your WordPress root, for example:
git clone https://github.com/pintxostudio/thebetterthread-wordpress wp-content/plugins/thebetterthread

Configure

  1. Create a site in the portal and copy the secret API key.
  2. Paste the key into the plugin settings. Keep it only in wp-admin — never in a theme file or a public repo.
  3. Choose criteria, thresholds, and start in shadow mode if you want scores without changing what commenters see.

Built for WordPress native comments. Form replacements such as wpDiscuz or Jetpack Comments need a separate integration.

Option 2

SDK + widget

Custom sites that want a drop-in coaching UI. Your browser talks to your backend. Your backend talks to us. The secret key never reaches the browser.

You need the Node.js SDK and the comment widget. Both are MIT. Until npm publish, depend on them from the source repository (for example as a git submodule or a local path).

1. Get an API key

Create a site in the portal and copy the secret API key. Keep it in your server environment — never in a browser bundle or a public client.

2. Create a score route

Your site owns this route. It receives commentText and contextId, looks up the article text on the server — do not trust context text from the browser — then calls the SDK.

import { Client, ApiError } from "@betterthread/sdk";

const client = new Client({
  apiKey: process.env.PLATFORM_API_KEY!,
  baseUrl: process.env.PLATFORM_API_URL!,
});

export async function POST(request: Request) {
  const body = await request.json();

  // Look up the article from body.contextId on your side.
  const contextText = await loadArticleText(body.contextId);

  try {
    const result = await client.score({
      commentText: body.commentText,
      contextId: body.contextId,
      contextText,
    });
    return Response.json(result, { status: 201 });
  } catch (error) {
    if (error instanceof ApiError) {
      return Response.json(
        { code: error.code, message: error.message, field: error.field },
        { status: error.status },
      );
    }
    throw error;
  }
}

Return the SDK response as JSON. On API errors, return { code, message } so the commenter can still post if the check fails.

3. Mount the widget

Attach the widget to your existing form. It intercepts submit, scores through your route, then lets the form post when the outcome allows it.

import { mount } from "@betterthread/widget";
import "@betterthread/widget/widget.css";

mount({
  form: "#commentform",
  textarea: "#comment",
  scoreUrl: "/api/score",
  contextId: "article-42",
  similarCommentUrl: "/comments/{id}",
});

What the commenter sees:

  • Passed — the form posts as usual.
  • Failed — short messages for each missed criterion. They can edit and try again. No “Post anyway.”
  • Warning — same messages, plus “Post anyway” (advisory criteria only).
  • Shadow mode — scored on your side, nothing shown to the commenter.

Prefer a programmatic post? Pass onPost(comment) instead of form. Do not pass both.

mount({
  textarea: "#comment",
  scoreUrl: "/api/score",
  contextId: "article-42",
  onPost: async (comment) => {
    await saveComment(comment);
  },
});

4. Keep the originality index in sync

Only needed if you turn Original on in the portal. When a comment goes live or is edited, index it. When it is deleted or erased, remove it. We store an embedding and your comment id — not the comment text. Send contextId when the post has a stable id; otherwise send contextText.

// After the comment is published on your site:
await client.putComment(commentId, {
  commentText,
  contextId,
});

// When it is deleted or erased:
await client.deleteComment(commentId);

SDK methods

  • score(body) — score a draft comment.
  • getPolicy() — read the site policy.
  • putComment(id, body) — add or update a published comment in the originality index.
  • deleteComment(id) — remove it from the index.

Failed calls throw ApiError with status, code, message, and optional field.

Option 3

SDK + custom UI

Custom sites that want full control of the coaching surface. Same Node.js SDK and score route — you render the response yourself.

You need the Node.js SDK. The widget is optional reference material. Until npm publish, depend on the SDK from the source repository (for example as a git submodule or a local path).

1. Get an API key

Create a site in the portal and copy the secret API key. Keep it in your server environment — never in a browser bundle or a public client.

2. Create a score route

Your site owns this route. It receives commentText and contextId, looks up the article text on the server — do not trust context text from the browser — then calls the SDK.

import { Client, ApiError } from "@betterthread/sdk";

const client = new Client({
  apiKey: process.env.PLATFORM_API_KEY!,
  baseUrl: process.env.PLATFORM_API_URL!,
});

export async function POST(request: Request) {
  const body = await request.json();

  // Look up the article from body.contextId on your side.
  const contextText = await loadArticleText(body.contextId);

  try {
    const result = await client.score({
      commentText: body.commentText,
      contextId: body.contextId,
      contextText,
    });
    return Response.json(result, { status: 201 });
  } catch (error) {
    if (error instanceof ApiError) {
      return Response.json(
        { code: error.code, message: error.message, field: error.field },
        { status: error.status },
      );
    }
    throw error;
  }
}

Return the SDK response as JSON. On API errors, return { code, message } so the commenter can still post if the check fails.

3. Call the route and render coaching

On submit (or before publish), POST to your score route and drive your UI from the JSON:

const response = await fetch("/api/score", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    commentText,
    contextId: "article-42",
  }),
});

const result = await response.json();
// result.outcome, result.enforcement, result.criteria[], result.similarCommentId
  • enforcement: "shadow" — score on your side, show nothing, publish as usual.
  • outcome: "passed" — publish.
  • outcome: "failed" — show each failed criterion's message. Offer “Post again.” Do not offer “Post anyway.”
  • outcome: "warning" — same messages, plus “Post anyway” (advisory misses only).
  • When a failed criterion includes similarCommentId, offer “Reply to this instead” with a link to that comment on your site.
  • If the route errors or times out, stop waiting and let the commenter post. Prefer fail-open.

Match the widget source unless you have a reason not to. Try a live check on the Demo page; the raw request and response are shown there.

4. Keep the originality index in sync

Only needed if you turn Original on in the portal. When a comment goes live or is edited, index it. When it is deleted or erased, remove it. We store an embedding and your comment id — not the comment text. Send contextId when the post has a stable id; otherwise send contextText.

// After the comment is published on your site:
await client.putComment(commentId, {
  commentText,
  contextId,
});

// When it is deleted or erased:
await client.deleteComment(commentId);

SDK methods

  • score(body) — score a draft comment.
  • getPolicy() — read the site policy.
  • putComment(id, body) — add or update a published comment in the originality index.
  • deleteComment(id) — remove it from the index.

Failed calls throw ApiError with status, code, message, and optional field.

Option 4

HTTP API

Call the customer /v1 contract directly with your secret API key. Same four operations as the Node.js SDK — no SDK required.

Authenticate every call with Authorization: Bearer sk_…. Call from your server only — the secret key never reaches the browser. Portal and sign-in routes are not part of this contract.

1. Get an API key

Create a site in the portal and copy the secret API key. Keep it in your server environment — never in a browser bundle or a public client.

2. Call the score endpoint

From your backend, look up the article text for contextId — do not trust context text from the browser — then POST /v1/comments/score.

const baseUrl = process.env.PLATFORM_API_URL!; // e.g. http://127.0.0.1:3000
const apiKey = process.env.PLATFORM_API_KEY!;

// Look up the article from contextId on your side.
const contextText = await loadArticleText(contextId);

const response = await fetch(`${baseUrl}/v1/comments/score`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${apiKey}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    commentText,
    contextId,
    contextText,
  }),
});

const result = await response.json();
// result.outcome, result.enforcement, result.criteria[], result.similarCommentId

Use outcome, enforcement, and criteria the same way as Option 3. Prefer fail-open if the request errors or times out. Optional: GET /v1/policies to read thresholds and advisory flags.

3. Keep the originality index in sync

Only needed if you turn Original on in the portal. When a comment goes live or is edited, index it. When it is deleted or erased, remove it. We store an embedding and your comment id — not the comment text. Send contextId when the post has a stable id; otherwise send contextText.

// After the comment is published on your site:
await fetch(`${baseUrl}/v1/comments/${encodeURIComponent(commentId)}`, {
  method: "PUT",
  headers: {
    Authorization: `Bearer ${apiKey}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    commentText,
    contextId,
  }),
});

// When it is deleted or erased:
await fetch(`${baseUrl}/v1/comments/${encodeURIComponent(commentId)}`, {
  method: "DELETE",
  headers: {
    Authorization: `Bearer ${apiKey}`,
  },
});

Reference

  • POST /v1/comments/score — score a draft comment.
  • GET /v1/policies — read the site policy.
  • PUT /v1/comments/{commentId} — add or replace an indexed comment.
  • DELETE /v1/comments/{commentId} — remove it from the index.

Browse the interactive reference at /api-docs, or download the OpenAPI file at /openapi.yaml.

Ready to wire it up?

Create a free account, grab a key, and pick the integration that fits your site. No card.