Structured Outputs and JSON Schema in Precise Lead Fit Scoring
Lead Qualification 12 min
0/21
Business problem
Prompt instructions like "respond strictly in JSON" fail in 5-10% of real-world runs: models append conversational markdown fences, alter key casing, or output trailing commas. These syntax exceptions break automated execution in n8n/Make, stranding pipeline without qualification.
Proven method
Native Structured Outputs mathematically guarantee model adherence to your defined JSON Schema:
| Schema Property | Qualification Role | Sample JSON Schema Rule |
|---|---|---|
| strict: true | Zero schema drift tolerance | Extra undocumented keys are rejected by the API parser |
| enum | Rigid segment categorization | |
| minimum / maximum | Score bounding constraints | |
| required | Mandatory data presence | |
- Define a strict JSON Schema reflecting your qualification and ICP scoring criteria.
- Include
response_format: { type:in your OpenAI payload or configure function tools in Claude/Gemini.json_schema
, json_schema: { strict: true, ... } } - Include a controlled
disqualification_flagsarray so negative filters are recorded systematically. - Pipe parsed attributes straight into CRM properties without regex cleansing or try/catch workarounds.
Market example
- BAD
- Prompt in n8n asking 'Return JSON with fit and reason'. The model outputs: 'Sure! Here is your assessment: ``
json {``', immediately throwing SyntaxError in Make's JSON parser.fit
:high
,reason
:Growing team
} - GOOD
- Native Structured Output configuration with 'strict: true'. The model outputs pure, validated JSON containing keys 'tier', 'fit_score_numeric', 'pain_points', and 'next_action'. Zero parsing exceptions across 10,000 processed leads.
Ready-to-use prompt
You are an AI Data Architect integrating LLMs with sales CRM systems. Context: I am automating lead qualification for inbound demo requests and webhooks. ICP Criteria: - Target Industries: [INDUSTRIES — e.g., B2B SaaS, Logistics, FinTech] - Minimum Headcount: [MIN EMPLOYEES — e.g., 20+] - Disqualification Triggers: [e.g., students, solo agencies, non-working website] Task: 1. Construct a production JSON Schema object with "strict": true for OpenAI's response_format API parameter. 2. Incorporate the following fields: - "qualification_status" (enum: TIER_1, TIER_2, DISQUALIFIED) - "icp_fit_score" (integer 0-100) - "identified_signals" (array of strings) - "disqualification_reason" (string or null) - "suggested_routing" (enum: AE_SENIOR, SDR_OUTREACH, NURTURE_EMAIL) 3. Write the accompanying system prompt guiding the model on weighting criteria prior to schema generation. Format: Valid JSON Schema specification plus system prompt instructions.
Model rekomendowany: Claude 3.5 Sonnet / GPT-4o Copy and paste into ChatGPT, Claude or Perplexity
ALTERNATYWNE SCENARIUSZE
Variations & alternative scenarios
Claude 3.5 implementation: forced structured outputs using tool_choice: { type: "tool", name: "qualify_lead" }.
Python/FastAPI pipeline: Pydantic schema validation using the instructor library.
Practical exercise
Configure a workflow step using structured JSON Schema outputs and test it against a malformed lead payload, verifying that the output parses directly without parsing errors.
Zapisano w przeglądarce