Advanced · Automation and agents · module 114 of 155
Checking structured output
Have AI give results in a fixed format and check them before a next step uses them.
After this lesson
You describe a schema, check output for format and allowed values, and choose what happens with invalid output.
In view · Step by step
Checking output before it moves on
Fields, types and permitted values are fixed in advance.
Required fields, format and limits are checked, not by the AI itself.
After one failed repair attempt, the case goes to a queue.
Part 1 of 3 · Schema
Your preference for less movement is on. Choose each part yourself.
A fixed format makes processing possible
If you want AI output to be processed by a spreadsheet, a form or another application, ask for a fixed format, for example a table or JSON with fixed fields (lesson 48). For each field, describe the name, the type and the allowed values: a date as YYYY-MM-DD, an amount as a number without a currency sign, a status that may only be new, in progress or done. Some tools can enforce such a schema. Even then, a check of the content is still needed: a valid format can still contain a wrong value.
Check before you pass it on
Have a simple check review every result before a next step uses it. Are all required fields present? Is the type correct? Does a value fall within the allowed list or limits? An amount of minus two hundred or a month 13 may fit in the field, but it is wrong. Such a check can sit in a spreadsheet, a script or your automation tool (lessons 79 and 88). Do not let the AI confirm by itself that its output is valid; a check that does its own calculations is more reliable.
One correction attempt, then a safe way out
If the output is invalid, you can ask for a correction once, including the specific error message: the date field is not in the format YYYY-MM-DD. If that attempt also fails, stop and put the case in a queue for a person (lesson 91). Do not keep retrying endlessly: that costs time and money and does not fix an unclear source. Count how often output is invalid. A rising number points to a problem in the input, the prompt or the model.
New practice example
From explanation to a usable result.
Ask for output in a fixed schema and have a check review that output before a next step uses it.
Fictional practice situationFictional schema for repair reports: device (text), report_date (YYYY-MM-DD), priority (low, normal or high). AI output: device “coffee machine”, report_date “2026-13-02”, priority “urgent”.
View a possible solution
This is how it can be done
The device field is valid. The report_date field follows the pattern, but month 13 does not exist: invalid. The priority “urgent” is not in the list: invalid. I ask for one correction attempt with both error messages. If that fails, the report goes to a staff member.
Why this works
A check on the pattern alone would have let the impossible date through. Permitted values and limits make the check stronger.
Make it slightly more difficult
For a schema of your own, write two validation rules: one for the format and one for a limit or a list of permitted values.
Extra practice, at your own pace. You do not need to submit anything. This does not count towards an automatic assessment.
Your workplace · learning by doing
Make something. See what changes.

Checking the AI connection… You can already view the written example.

Present your assignment to Ende.
Read the answer, change one thing, and compare.
Previously held
New version
You remain in control
What do you want to improve in your next attempt?
On this device only. AI answers remain only in this page memory. This is self-review, not a grade.
Why this approach works
A check on the pattern alone would have let the impossible date through. Permitted values and limits make the check stronger.
A step further
For a schema of your own, write two validation rules: one for the format and one for a limit or a list of permitted values.
Try & discover · no obligation
Become the source checker yourself
Only mark statements that the source does not support. Then check your selection.
Schema: naam (text), datum (YYYY-MM-DD, or null if it is missing), aantal_personen (whole number from 1 to 50), status (only new, in progress or done). Below are the fields from one AI output.
Select which sentences you would correct above. The answer remains hidden until you check your selection.
This trial works locally with fictitious data and does not count towards your lesson completion. It starts anew with a new lesson or reload.
A prompt to get you started
Convert the fictional request below to JSON with exactly these fields: naam (text), datum (YYYY-MM-DD), aantal_personen (whole number between 1 and 50) and status (only “new”). Use only data from the request. If a required field is missing, set it to null and add a list ontbrekend with the name of that field. Give only the JSON. Request: “I’m Noor and I would like to book the hall for twelve people. I’ll let you know the date later.”
Apply it
A workflow automatically puts AI output into a spreadsheet. Sometimes the date column says “soon” and the sheet calculates incorrectly.
Which approach best fits this situation?
- Add a schema check before the spreadsheet, with one repair attempt and then a queue for a person.
- Let the spreadsheet ignore the error itself.
- Ask the AI in the prompt never to write “soon” again and check nothing else.
With JavaScript, you can check your approach and receive immediate feedback.
Test your insight
After one correction attempt, an output still has an invalid date. What is the best next step?
- Keep repeating until the date is valid.
- Stop the case and put it in a queue for human oversight.
- Fill in today’s date yourself so that the workflow keeps running.
Extra practice
For one AI output from your work, write a schema of four fields with type and allowed values. Check three outputs against that schema and note which check caught an error.
{"naam": "Noor", "datum": null, "aantal_personen": 12, "status": "new", "ontbrekend": ["datum"]}. Check: all fields present, aantal_personen is a whole number between 1 and 50 and status is in the list. The date is rightly null: it is not in the request. An output with "datum": "next week" would not pass the format check.

