AI Sales Academy

Structured Outputs and JSON Schema in Precise Lead Fit Scoring

Lead Qualification 12 min
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 PropertyQualification RoleSample JSON Schema Rule
strict: trueZero schema drift toleranceExtra undocumented keys are rejected by the API parser
enumRigid segment categorizationtier: { type: string, enum: [TIER_1, TIER_2, UNQUALIFIED] }
minimum / maximumScore bounding constraintsscore: { type: integer, minimum: 0, maximum: 100 }
requiredMandatory data presencerequired: [tier, score, justification, buying_triggers]
  1. Define a strict JSON Schema reflecting your qualification and ICP scoring criteria.
  2. Include response_format: { type: json_schema, json_schema: { strict: true, ... } } in your OpenAI payload or configure function tools in Claude/Gemini.
  3. Include a controlled disqualification_flags array so negative filters are recorded systematically.
  4. 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 {fit: high, reason: Growing team} ``', immediately throwing SyntaxError in Make's JSON parser.
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

Steps to take

0/4