Saltar al contenido principal

AI Lead Qualifier

Convierte cada consulta entrante en JSON puntuado y listo para tu CRM con Claude.

  • Python
  • FastAPI
  • Pydantic
  • Anthropic Python SDK
  • Uvicorn

Capturas de pantalla

Captura 1 de 7: Portada de "AI Lead Qualifier — código fuente en Python" con un lead calificado en JSON: intención sales_inquiry, Greenleaf Organics, presupuesto de unos 15.000 $, puntuación 95 y prioridad alta.

Portada de "AI Lead Qualifier — código fuente en Python" con un lead calificado en JSON: intención sales_inquiry, Greenleaf Organics, presupuesto de unos 15.000 $, puntuación 95 y prioridad alta.

Pago único

  • 1499 INR+ GST al pagar
  • 29 US$
  • Descárgalo desde tu biblioteca en cuanto se confirme tu pago.
  • Incluye todas las versiones futuras de este proyecto, sin costo adicional.
Última versión
1.0.0 · 14 oct 2026

Descripción general

Un servicio ligero en Python y FastAPI que envía una consulta comercial breve a la API de Claude y devuelve JSON estructurado: los datos clave, la intención, una puntuación de 0 a 100 con prioridad y sus motivos, un resumen breve y una respuesta sugerida, listo para pasar a tu CRM.

Clasificar consultas a mano es lento, y los buenos leads esperan mientras alguien lee spam. AI Lead Qualifier hace ese primer filtro por ti. Envía una consulta a un único endpoint de la API y recibe JSON limpio y estructurado en pocos segundos.

Claude extrae el nombre, el correo, el teléfono, la empresa, el cargo, la ubicación, el presupuesto, el plazo y los requisitos del remitente tal como están escritos. No se inventa nada: lo que el mensaje no dice se devuelve como null. Clasifica la intención como consulta comercial, solicitud de soporte, alianza, candidatura de empleo, oferta de proveedor, spam u otra, escribe un resumen de una o dos frases y redacta una respuesta firmada con el nombre de tu empresa para que una persona la revise antes de enviarla.

La puntuación la calcula Python, no el modelo. Una tabla de puntuación transparente convierte las señales que detecta Claude (presupuesto, urgencia, poder de decisión, una necesidad concreta, una petición de reunión) en una puntuación de 0 a 100, una prioridad alta, media o baja y una lista de motivos como "+20 Budget mentioned". Las puntuaciones son coherentes, explicables y fáciles de ajustar, y ningún mensaje puede convencer al sistema de darle prioridad alta. Las consultas se tratan como datos, nunca como instrucciones, así que los intentos de inyección de prompt se clasifican en lugar de obedecerse.

Está preparado para producción. Los resultados siempre cumplen el esquema gracias a las salidas estructuradas de Claude. Cada problema con la API de Claude se convierte en un estado HTTP claro (422, 502, 503 o 504) con un ID de solicitud, y los registros guardan intención, puntuación, tokens y duración sin ningún dato de clientes. El prompt del sistema se almacena en caché para reducir costes, y puedes cambiar de modelo de Claude y de nivel de esfuerzo en un único archivo de configuración.

El código es pequeño, tipado y está totalmente probado. 39 pruebas de pytest se ejecutan en menos de un segundo con un analizador simulado, así que nunca llaman a Claude ni cuestan nada. Adapta el prompt, los campos extraídos o la tabla de puntuación a tu negocio en archivos claramente señalados.

¿Quieres ver cómo se construyó? La serie gratuita de tutoriales paso a paso "Build an AI Lead Qualification Agent with Claude and Python" (en inglés) recorre cada archivo de este proyecto: https://devblogs.dewiride.com/series/claude-api/ai-lead-qualification-agent-claude-python (se abre en una pestaña nueva)

Serie de tutoriales gratuita

Build an AI Lead Qualification Agent with Claude and Python

¿Prefieres aprender construyéndolo? Esta guía gratuita y paso a paso en nuestro blog muestra cómo se hace el proyecto.

Leer la serie (se abre en una pestaña nueva)

Qué te llevas

Todo lo que hay en el archivo, de un vistazo.

  • Código fuente completo en Python de la versión 1.0.0
  • Una app FastAPI con un endpoint, POST /api/v1/leads/qualify, y una comprobación de estado
  • Salidas estructuradas de Claude basadas en modelos de Pydantic
  • Una tabla de puntuación transparente de 0 a 100 con prioridad y motivos, calculada en Python
  • Respuestas de error claras (422, 502, 503, 504) con ID de solicitud en cada respuesta
  • Registros seguros con uso de tokens y sin datos de clientes
  • Un prompt del sistema en caché que puedes editar en un único archivo Markdown
  • 39 pruebas de pytest sin conexión que nunca llaman a la API de Claude
  • uv.lock con las versiones exactas de los paquetes con las que se probó
  • Un README con instalación, configuración, referencia de la API y guía de personalización
  • Una plantilla .env.example para cada ajuste

Construido con

Los entornos y las versiones exactos con los que se creó y se probó.

  • Python3.14
  • FastAPI0.143.0
  • Pydantic2.14.1
  • Anthropic Python SDK1.13.0
  • Uvicorn0.54.0
  • pytest9.1.1

Qué contiene el archivo

El árbol de carpetas que obtienes al descomprimirlo.

ai-lead-qualifier/

  • src/
    • lead_qualifier/
      • __init__.py
      • main.py
      • config.py
      • models.py
      • prompts.py
      • system_prompt.md
      • analyzer.py
      • scoring.py
      • logging_config.py
      • api/
        • __init__.py
        • health.py
        • leads.py
        • errors.py
        • middleware.py
  • tests/
    • conftest.py
    • test_api.py
    • test_models.py
    • test_prompts.py
    • test_scoring.py
    • data/
      • greenleaf-analysis.json
  • .env.example
  • .gitignore
  • .python-version
  • pyproject.toml
  • uv.lock
  • README.md

Qué necesita de ti

Las cuentas y los servicios que espera encontrar, para que nada te sorprenda.

  • uv, que instala Python 3.14 por ti
  • Una clave de la API de Claude en una cuenta de Anthropic con saldo (Anthropic factura el uso de la API)
  • Soltura básica ejecutando comandos en una terminal
  • macOS, Windows o Linux

Versiones

Todas las versiones hasta ahora, de la más reciente a la más antigua.

  1. 1.0.0Más reciente

    Primera versión. Envía un mensaje breve de un lead a un endpoint de la API y recibe JSON listo para tu CRM: los datos de contacto que menciona, la intención, una puntuación de 0 a 100 con prioridad y motivos en lenguaje claro, un resumen breve y una respuesta sugerida. Incluye respuestas de error claras, ID de solicitud, registros sin datos personales y un conjunto completo de pruebas que se ejecuta sin llamar a la API de Claude.

Source Code Licence

Qué puedes hacer con él

What you may and may not do with the source code you buy.

Leer la licencia completa
  1. What this licence covers

This licence governs every file included in a product you buy from Dewiride Store: source code, configuration, database scripts, sample data, documentation and any other file in the download. It takes effect when your payment is confirmed and applies to every release of that product that reaches your library. Files that reach your library through an annual updates membership are governed in exactly the same way.

It forms part of the Terms of Sale and Use. Where a product page states different or additional licence terms for that product, those terms prevail for that product. The membership page may likewise state different or additional licence terms for the files a membership carries, and those terms then prevail for those files.

  1. The licence we grant you

We grant you a perpetual, worldwide, non-exclusive, non-transferable licence to use, reproduce, adapt, translate and modify the files, and to include the result in your own work, on the conditions set out below.

Perpetual means it does not expire. Worldwide means it is not limited to any country. Non-exclusive means we license the same product to other customers. Non-transferable means you cannot pass it on to someone else.

The licence is granted to you — either you personally, or the organisation you identified when buying. Everyone working within that organisation may use the files for that organisation’s projects. Nobody outside it may.

  1. What you may do
  • Use and change the files in your own projects, commercial or otherwise, with no limit on the number of projects.
  • Build a product or a service on them and charge your own customers for it.
  • Deploy the result for a client, as part of work you are doing for that client.
  • Distribute the result in compiled, deployed or otherwise non-source form.
  • Keep as many back-up copies as you reasonably need.
  • Study, observe and test how the code works, and obtain the information you need to make it work with your own software.

The last two are yours by law under sections 52(1)(aa) to (ac) of the Indian Copyright Act, 1957, and nothing in this licence is intended to take them away.

  1. What you may not do
  • Resell, sublicense, redistribute or publish the files themselves, in whole or in substantial part, in source form.
  • Include them in a template, starter kit, course, tutorial repository or component library that you sell or give away, where the code is the thing being supplied.
  • Share your account, your download links or your invoices with anyone outside your organisation.
  • Publish the files in a public repository, or in any other place where they can be obtained without buying them.
  • Remove or obscure the copyright and attribution notices in the source files.
  • Use the files to build something whose main purpose is to compete with Dewiride Store as a supplier of the same code.

The distinction that matters is simple: you may sell what you build with the code; you may not sell the code.

  1. Third-party components

Our products depend on open-source libraries, frameworks and services that we did not write. Those remain under their own licences, which we do not and cannot change. Where a product includes or requires such a component, its licence is named in the product’s documentation, and complying with it is your responsibility.

  1. Releases

Every release of a product you own is covered by this same licence and appears in your library at no extra cost. A release you have already downloaded remains licensed to you even if we later stop publishing the product. A release that reached your library through an annual updates membership is licensed to you on these same terms, and stays licensed after the period that carried it has ended.

  1. Ownership

We keep ownership of the files and of the copyright in them. You own whatever you create with them: your changes, your additions and the product you build are yours.

  1. If this licence ends

This licence ends if you materially breach it and do not put the breach right within thirty days of us asking you to in writing. It also ends if your payment is reversed or refunded, because the purchase it depends on no longer stands. Where a membership period is refunded or reversed, the licence ends for the releases that period carried and for nothing else: anything you bought separately, or that another period carried, is unaffected.

If it ends, you must stop using the files and delete the copies you hold. Work you had already delivered to a client before that point may continue in use, so that ending this licence never breaks something your own customer relies on.

  1. No warranty beyond the description

The warranties and limits in section 19 and section 20 of the Terms of Sale and Use apply to this licence as well.

  1. Governing law

This licence is governed by the law of India, and section 24 of the Terms of Sale and Use applies to any dispute about it. If a translation and the English version differ in meaning, the English version governs.