Make Any AI Step Fail Loudly, Not Silently

Roadblock: the AI step returned an empty string at 2 a.m. and your workflow happily emailed a blank message to a client. Validate the output and stop the run instead.

The Snippet

// Zapier/Make code step — gate AI output before it reaches a human
const text = (inputData.aiOutput || "").trim();
const refusals = ["as an ai", "i cannot", "i'm sorry"];
if (text.length < 20) {
  throw new Error("AI output too short — halting run");
}
if (refusals.some((r) => text.toLowerCase().startsWith(r))) {
  throw new Error("AI refused the task — halting run");
}
output = { text };

Implementation Steps

  1. Add a Code step right after your AI step
  2. Check length and obvious refusal phrases
  3. Throw to halt the run — silence is worse than failure

All templates