Extract Data From Text with AI
Free text in, named fields out. The extraction prompt pattern that turns any unstructured text into consistent, parseable records.
The most consequential setting in any extraction prompt: what the model does when the field isn't in the text. Four behaviors, and when each is right.
Every extraction eventually meets a text that doesn't contain the field — and what happens next is the difference between a reliable pipeline and silent garbage. Four contracts exist: Leave Empty (visible gap, human-friendly), Return Null (stable keys, pipeline-friendly), Return Unknown (loud gap a reviewer can't miss), and Skip Field (lean output, consumers must check key existence). This resource loads a sparse-by-nature lead-form extraction set to Return Unknown with strict ambiguity — the configuration where missing data is most visible — so you can see the contract language and swap behaviors to compare.
Match the behavior to the consumer
Code parsing the output wants Return Null; a human scanning a sheet wants Leave Empty or Return Unknown; Skip Field needs existence-checking consumers.
Swap behaviors and diff the prompt
Load this setup, change Missing Data, and watch the MISSING DATA block rewrite itself — the contract is two lines, and they do all the work.
Keep the never-invent rule
Whatever behavior you choose, the constant is "never invent or guess a value for a missing field" — the line every behavior shares.
Match the behavior to who consumes the output. The workflow maps it: code parsing the result wants Return Null for stable keys, a human scanning a sheet wants Leave Empty or Return Unknown, and Skip Field needs consumers that check key existence. This loaded set uses Return Unknown — a literal "unknown" string a reviewer can't miss — so you can see the contract, then swap behaviors to compare.
Two reinforcing rules. The MISSING DATA block says to return the literal "unknown" only for genuinely absent information and never invent or guess a value, and the AMBIGUITY POLICY adds that a value implied but not stated is treated as missing. That never-invent line is the constant across all four behaviors, so absence stays absence whichever contract you pick.
Only the MISSING DATA block rewrites — the workflow calls it a two-line contract that does all the work. The extraction-prompt-generator regenerates those lines when you change the setting, while FIELDS TO EXTRACT, EXTRACTION RULES, and the required/optional split (lead_name, email, use_case required) stay put. You still run the resulting prompt in your own assistant.
Free text in, named fields out. The extraction prompt pattern that turns any unstructured text into consistent, parseable records.
Invoice number, vendor, dates, total, currency — extracted into clean fields with strict no-inference rules, ready for accounts payable.
Parties, effective date, term, payment, termination notice, governing law — key terms into a contract register, with "unknown" marking every gap loudly.
Stop getting 'Sure, here is the JSON…' — the output-contract pattern that forces models to return only parseable JSON: schema, example, and a strict rule block.
Billing, Technical, Account, How-To, Feature Request — ticket triage with definitions that decide the borderline cases for the model.
The JSON won't parse and you can't see why. Deterministic cause-sniffing — trailing commas, single quotes, unclosed brackets — and the repair prompt that fixes it.
Build prompts that extract defined fields from unstructured text — emails, invoices, tickets, résumés.
When a source is missing a field, AI tends to fill the gap with a plausible guess instead of saying it isn't there. Here's how to make the model mark missing data explicitly — and check the result before you trust it.
"Summarize this transcript" turns suggestions into decisions, invents deadlines, and drops owners. Here's how to extract decisions, action items, owners, deadlines, and open questions instead — each with evidence and a needs_review flag, and "not stated" for what's missing.
AI extraction returns clean JSON that quietly means something different each run. Design the extraction schema first — each field's meaning, type, allowed values, missing-value rule, and required evidence — and review it before a single record is pulled.
Ask AI to extract fields with "use null if missing" and one null means missing, false, a stated "none", and a real zero — valid JSON, wrong meaning. Handle unknown vs empty vs not-applicable in AI output: give each field a value state so absence gets classified, not collapsed.