Turn a conversation into usable fields
Give the application a labeled form
Humans understand many ways of saying the same thing. Software benefits from consistent field names and types. JSON is a text format for labeled values, like a form the application can read.
In JSON, text uses quotation marks, numbers do not, true and false represent yes and no, and null means a deliberately empty value. A list uses square brackets.
For “Something spicy under $25 including fees; Thai would be nice,” this is a possible structured interpretation. Currency and dietary restrictions remain unknown:
{
"cuisine_preferences": [
"Thai"
],
"spice_preference": "spicy",
"budget_amount": 25,
"currency": null,
"includes_fees": true,
"dietary_restrictions": null,
"delivery_area": null
}Check your understanding
Match each request detail to its field.
Unknown is different from none
If the user has not mentioned dietary restrictions, use null. If they explicitly say “I have no dietary restrictions,” an empty list can represent that answer in our format. These states mean different things.
Keep inference modest. A dollar sign alone does not tell us which dollar currency is intended. Nor does a preferred cuisine establish someone’s location. Ask when an unknown becomes necessary for the task.
Check your understanding
The user never mentions dietary restrictions. What should our field contain?
Write a prompt the model can follow
A useful prompt states the task, input, rules, and output format. For example: “Extract dinner preferences from the supplied request. Preserve explicit requirements. Use null for unknown values. Return these seven fields as JSON. Do not recommend a restaurant or invent fees.”
Include a worked input and output if it helps explain the task. Keep instructions separate from the user’s request so quoted restaurant text does not silently become an application rule.
A schema defines expected fields and types. Provider structured-output features can constrain format, but your application must still check whether values make sense and match the request. See Google’s structured-output guidance.
Check your understanding
Improve this instruction: “Fill in all dinner preferences, guessing anything missing.”
Save your first extraction prompt
Write a reusable dinner preference extraction prompt. Include the seven field names shown above, the rule for unknown values, and one example request.
Key takeaways
- JSON gives software a consistent set of labeled values.
- Unknown and explicitly none need different representations.
- A prompt should name the task, rules, input, and output format.
- Correct structure does not guarantee correct meaning.