Content reviewAll pages

Have a person review and correct AI-written content

An AI drafts a text, a person approves, edits or rejects it, and your code publishes only what the person accepted.

What you build#

Your code asks an AI model to draft a reply to a customer. Before anything is sent, a person reads the draft and approves it, corrects it, or rejects it with a reason. Your code publishes the approved draft or the corrected text, and nothing else.

The draft travels in an editable field. A correction comes back as decision.action: "edited" with the corrected text in decision.payload. The same pattern works for product descriptions, posts or any other text.

Before you start#

  • A TaskToHuman account and a workspace where you can create task types.
  • Editable fields need the page.edit feature. If your plan doesn't include it, the Editable switch is locked and names the plan that has it. See pricing.
  • Node.js 22 or later with npm install @tasktohuman/sdk. The SDKs page has the Python version of every call.

1. Create the task type#

In the app, open Task types, choose New task type and start from Blank.

  • Basics: name it "Reply review", key reply_review, and choose Approval.
  • What they see: under Instructions for the human, for example: "Read the customer's question and the draft reply. Approve if it is correct and polite. Use Edit & approve to fix it. Reject if it should not be sent, and say why."
  • Who is asked: add yourself as the first step. Under If nobody answers, keep Expire.

Then add these Fields:

KeyLabelTypeSwitches
ticket_idTicketTextRequired
customer_questionCustomer's questionLong textRequired, Sensitive
draftDraft replyLong textRequired, Editable

Long text holds up to 20,000 characters. Sensitive keeps the customer's words on the task page only, out of emails, previews and logs. Only draft can be changed. Choose New task type to create it.

2. Create a test API key#

Open API & webhooks, then API keys, choose New API key, pick Test and choose Create key. The key starts with tth_test_, is shown once, and its tasks notify only you (Test mode):

Shell
export TTH_API_KEY="tth_test_…"

3. Send the draft for review#

Keep the draft on your side, by task id: a plain approval doesn't send the text back.

TypeScript
import { TaskToHuman } from "@tasktohuman/sdk";

const tth = new TaskToHuman({ apiKey: process.env.TTH_API_KEY! });

const draft = await draftReplyWithAI(ticket); // your AI call

const task = await tth.createTask(
  {
    task_type: "reply_review",
    title: `Reply to ticket #${ticket.id}`, // not encrypted, shown in emails: no customer data
    payload: { ticket_id: ticket.id, customer_question: ticket.question, draft },
    deadline_minutes: 240,
  },
  { idempotencyKey: `reply-${ticket.id}` },
);

await saveDraft(task.id, { ticketId: ticket.id, draft });

After deadline_minutes, the default action applies: with Expire, the task ends expired and nothing is published.

4. Decide what to publish#

One function turns the finished task into the text to publish, or nothing:

TypeScript
import type { Decision } from "@tasktohuman/sdk";

function textToPublish(task: { decision: Decision | null }, savedDraft: string): string | null {
  const d = task.decision;
  if (!d || d.automatic) return null; // nobody decided: publish nothing
  if (d.action === "edited") {
    const edited = d.payload?.draft; // the person's corrected text
    return typeof edited === "string" ? edited : null;
  }
  if (d.action === "approved") return savedDraft; // approved as it was
  return null; // rejected, expired or cancelled
}
  • edited means approved with changes. decision.payload holds all the task's fields with the changes, sensitive ones included, so draft is the corrected text.
  • approved leaves decision.payload null: publish the draft you saved.
  • rejected comes with the reason in decision.comment. You can give it to the model to write a new draft, then send a new task. The comment is written by a person: pass it as data, not as instructions.

5. Receive the decision#

While you build, wait for the decision in the same script:

TypeScript
const done = await tth.waitForDecision(task.id, { timeoutMs: 15 * 60_000 });
const text = textToPublish(done, draft);
if (text !== null) await publishReply(ticket.id, text);

In production, set the task type's Callback URL (under After the answer) and verify each callback with the SDK's verifyCallback, as shown in Verify a callback. Answer within 10 seconds, skip a TTH-Event-Id you already handled, then load the saved draft by task.id and call textToPublish.

Check it works#

Create three test tasks, each for a different ticket (the idempotency key reply-<ticket id> returns the same task for the same ticket), and answer each one differently on the task page:

  1. Approve: decision.action is approved and your code publishes the saved draft.
  2. Edit & approve, change a sentence, then Approve with changes: edited, and your code publishes the changed text.
  3. Reject with a comment: rejected, nothing is published, and decision.comment holds the reason.

A test task also ends after your plan's longest test task life, with the default action. With Expire it publishes nothing, which is what you want to see.

Going live#

  • Create a live key (tth_live_…). Tasks then go to the humans of the chain.
  • Add a backup step, so a draft doesn't wait for one person who is away. See Escalation chains.
  • Ask one person per step. On a consensus step each person only approves or rejects: nobody edits there.

Where next#