A language model can read a contact form and say whether the lead looks like a good fit. That is useful. It is also easy to overtrust. This guide shows a small, honest build: define a good lead, score with simple rules first, add a model that returns a strict JSON result, test it on past leads and keep a person in charge. It makes no claim about accuracy. You must measure that on your own data.
What this build does
Lead scoring gives each new enquiry a number that says how well it fits what you sell. The score helps you reply first to the leads that matter.
The model reads the free-text parts of a form, such as the message and the company description. It returns a short, structured result. A person decides what to do with it.
Step 1: start with plain rules
Do not begin with a model. Begin with the rules you could write on a sticky note.
| Signal | Example rule |
|---|---|
| Budget stated | Add points if the budget fits your lowest package |
| Timeline | Add points if the project starts within three months |
| Service match | Add points if they ask for something you sell |
| Contact quality | Subtract points for a throwaway email or an empty message |
These rules are my own examples. Change them to match your business. Keep this baseline. You will need it to judge the model.
Step 2: force a strict output
Free text from a model is hard to use. A fixed shape is easy. OpenAI Structured Outputs makes a response follow a JSON Schema you supply, using strict mode.1
JSON mode only helps the output be valid JSON. Structured Outputs aims at matching your schema.1 The model can also refuse, and then a refusal field is set.1
1from openai import OpenAI2import json34client = OpenAI()56schema = {7 "type": "object",8 "properties": {9 "fit": {"type": "integer", "enum": [1, 2, 3, 4, 5]},10 "reasons": {"type": "array", "items": {"type": "string"}},11 "missing_info": {"type": "array", "items": {"type": "string"}},12 "needs_human": {"type": "boolean"}13 },14 "required": ["fit", "reasons", "missing_info", "needs_human"],15 "additionalProperties": False16}1718resp = client.chat.completions.create(19 model="YOUR_MODEL_NAME",20 messages=[21 {"role": "system", "content": "Score the lead from 1 to 5 for fit. Use only the text given. If unsure, set needs_human to true."},22 {"role": "user", "content": lead_text},23 ],24 response_format={25 "type": "json_schema",26 "json_schema": {"name": "lead_score", "strict": True, "schema": schema},27 },28)29result = json.loads(resp.choices[0].message.content)| Limit | What the announcement says |
|---|---|
| Schema support | Only a subset of JSON Schema is supported1 |
| First request | A new schema adds latency to the first request1 |
| Cut-off output | If output stops early, such as at max_tokens, it may not match the schema1 |
| Wrong values | Values can still be wrong even when the shape is right1 |
Step 3: test on past leads
A schema makes the shape reliable. It does not make the score right. Test it.
- 1
Collect past leads
Pull 50 to 100 old enquiries where you know what happened: won, lost or ignored.
- 2
Remove private data
Strip names, emails and phone numbers before you send any text to a model.
- 3
Score them blind
Run the model without showing it the outcome.
- 4
Compare with outcomes
Check how often high scores became customers, and how often low scores did.
- 5
Compare with your rules
Does the model beat the sticky-note baseline? If not, keep the baseline.
- 6
Read the misses
Look at every wrong call. They show what your prompt or schema lacks.
Step 4: wire it in safely
| Rule | Why |
|---|---|
| Never auto-reject | A wrong low score would silently lose a real customer |
| Show the reasons | A person can spot a bad call in seconds |
| Route needs_human to a person | Unsure cases should not be guessed |
| Log every score and every outcome | You need data to improve and to audit |
| Re-run the back-test each quarter | Your market and your prompt both drift |
How I would approach it
I would build the rules first and ship them. They work on day one, and they set the bar.
I also would not publish a result like “improves conversion by X percent” unless I had measured it on a real pipeline. This guide has no such number.
Common mistakes
Skipping the simple rule baseline.
Trusting the score without a back-test.
Sending raw personal data to a model.
Letting the score reject leads automatically.
Never checking the results again after launch.
Quick questions
Does a strict schema make the score accurate?
No. It makes the shape reliable. The values can still be wrong.1
How many past leads do I need?
There is no fixed number. Fifty to a hundred is a practical start for a small business, but treat the result as a sanity check.
Can I use a different model provider?
Yes. Many providers offer a way to return structured output. The same steps apply: baseline, schema, back-test, human review.
Should the model write the reply too?
Keep that separate. Scoring and writing are different jobs, and a person should review any message that goes out.
Key takeaways
A model suggests a lead score. A person decides.
Build a plain rule baseline first and keep it.
Use a strict JSON schema so the output has a reliable shape.
A valid shape does not mean a right answer. Back-test on past leads.
Never auto-reject, show the reasons and keep a log.
