Topic 2 of 5 · 4 min read
Turning emails and notes into fields
Goal: Extract structured fields from free text, leaving missing values blank, and catch a field the model invented.
To turn an email or a note into fields, list the fields you want, tell the model to leave any missing value blank, and check every filled value against the text. Models are good at reading messy writing. They are also eager to be helpful, and a blank looks like a failure to them.
Check yourself · 1 of 3
An email gives a customer name and an item but no order number. What should the extraction return for the order number?
Why it matters
Orders, complaints and bookings arrive as sentences, not forms. Someone has to copy the order number, the amount and the date into a sheet. A chat model can do this for 50 emails in a few minutes. But when the email does not contain the order number, a model may return one that looks right. That row then goes into your records, and nobody notices until a customer calls.
How to do it
- List the fields and their types. For example: Customer name, Order number, Amount, Currency, Date, Request. Say which are text, which are numbers, and which are dates.
- Give the blank rule. Write: "If a field is not stated in the text, leave it empty. Never guess, and never copy a value from another field."
- Ask for evidence. Add a column with the exact words from the email that support each value. A value with no quote is a warning sign.
- Handle several values. If an email mentions two orders, say whether you want two rows or one row with both.
- Check the filled values. Search the email for each number and name the model returned. If the text does not contain it, the model invented it.
Before and after
Take this email: "Hi, I ordered a blue jacket last Tuesday and it still has not arrived. Please check. Thanks, Maria."
Before: Extract the order details from this email.
A typical answer lists Customer: Maria, Item: blue jacket, Order number: 48213, Date: last Tuesday. The order number is not in the email. The model made it up.
After: From the email below, extract Customer, Item, Order number, Order date and Request. Use only what the email states. If a field is missing, write MISSING. Do not convert "last Tuesday" into a date. Add a Quote column with the words you used.
Now the answer shows Order number: MISSING and Order date: MISSING. That is the correct result, and it tells you to ask Maria.
What goes wrong
- Invented values. An order number, a postcode or a surname that the text never gave.
- Values moved between fields. A phone number lands in the order number field because both are digits.
- Relative dates turned into real ones. "Last Tuesday" becomes a specific date, computed from the wrong today.
- The first match wins. An email with two amounts returns only one, and nothing says another existed.
Examples
The order number that was never there
An email says: "Where is my jacket? I ordered it a week ago, Maria Lopez." The model returns Order number 48213. Searching the email for 48213 finds nothing. Re-running with the rule "write MISSING if not stated" returns MISSING, and the clerk asks Maria for the number.
Two amounts, one row
A note says: "Please refund 40 euros for the late delivery and 15 euros for the broken box." The model returns Amount 40. The fix is in the prompt: "One row per refund request; this note has two." The sheet now has 40 and 15, and the total refund is 55.
Key points
- List the fields, their types and what to return when a field is missing; a blank rule is part of the prompt.
- Ask for a quote from the text next to each value so you can check it.
- A value that does not appear in the source is invented, and a search for it takes seconds.
- Relative dates such as last Tuesday should stay as written or be flagged, not turned into a calendar date.
- State what to do with several orders or amounts in one message.
Common mistakes
- Not telling the model what to do with a missing field, so it fills the gap.
- Reading the output for sense instead of searching the source for each value.
- Letting the model turn relative dates into calendar dates without today's date.
- Sending a long email thread and expecting one clean row from it.
Check yourself · 2 of 3
A model extracts the order number 48213 from an email. What is the fastest reliable check?
Check yourself · 3 of 3
Which prompt line best protects against made-up values?
Practice items, not counted towards your mastery.
Start here
- OpenRefine (opens in a new tab)ToolFree
A free desktop tool for clustering name variants and fixing a column in bulk, with every step recorded.
- Tabula: extract tables from PDFs (opens in a new tab)ToolFree
Free tool that pulls tables out of text-based PDFs without a language model, a useful cross-check.
- Vision (Claude docs) (opens in a new tab)DocsFree
What image and PDF reading can and cannot do, including limits on small text and tables.
More for this topic
- Structured outputs (Claude docs) (opens in a new tab)DocsFree
How to make a model return data that fits a fixed schema.
- Structured model outputs (OpenAI API docs) (opens in a new tab)DocsFree
The same idea from another vendor: a JSON schema the answer must follow, including optional fields.