AI Lead Qualifier
Claude で、届いた問い合わせをすべてスコア付きの CRM 対応 JSON に。
- Python
- FastAPI
- Pydantic
- Anthropic Python SDK
- Uvicorn
スクリーンショット
- 最新リリース
- 1.0.0 · 2026/10/14
- ライセンス
- Source Code Licence
概要
短い営業問い合わせを Claude API に送り、構造化された JSON を返す、Python と FastAPI で作った軽量サービスです。主要な情報、意図、優先度と理由付きの 0〜100 のリードスコア、短い要約、返信の提案を返し、そのまま CRM に渡せます。
問い合わせを手作業で仕分けるのは時間がかかり、誰かがスパムを読んでいる間に有望なリードが待たされます。AI Lead Qualifier はその最初の仕分けを代わりに行います。問い合わせを 1 つの API エンドポイントに送るだけで、数秒できれいな構造化 JSON が返ってきます。
Claude は送信者の名前、メール、電話番号、会社、役職、所在地、予算、時期、要件を、書かれているとおりに抽出します。推測はしません。メッセージに書かれていない項目は null になります。意図は営業問い合わせ、サポート依頼、提携、求人応募、業者からの売り込み、スパム、その他に分類され、1〜2 文の要約と、御社名で署名した返信案が作成されます。返信案は送信前に担当者が確認します。
スコアはモデルではなく、通常の Python で計算します。透明なスコアカードが、Claude の見つけたシグナル(予算、緊急度、決裁権限、具体的なニーズ、打ち合わせの依頼)を 0〜100 のスコア、high・medium・low の優先度、そして「+20 Budget mentioned」のような理由の一覧に変換します。スコアは一貫性があり、説明でき、調整も簡単です。メッセージの書き方で優先度を高くさせることはできません。問い合わせは指示ではなく常にデータとして扱われるため、プロンプトインジェクションの試みは実行されず、分類されます。
本番運用を前提に作られています。Claude の構造化出力により、結果は常にスキーマどおりです。Claude API で起きた問題はすべて、リクエスト ID 付きの明確な HTTP ステータス(422、502、503、504)になり、ログには意図、スコア、トークン数、処理時間だけが記録され、顧客データは残りません。システムプロンプトはキャッシュされてコストを抑え、Claude のモデルと effort レベルは 1 つの設定ファイルで切り替えられます。
コードはコンパクトで型付けされ、十分にテストされています。39 個の pytest テストはフェイクの analyzer を使って 1 秒未満で終わるため、Claude を呼び出さず費用もかかりません。プロンプト、抽出する項目、スコアカードは、わかりやすく分かれたファイルでビジネスに合わせて変更できます。
どのように作られたか知りたい方へ。無料のステップバイステップのチュートリアルシリーズ「Build an AI Lead Qualification Agent with Claude and Python」(英語)で、このプロジェクトのすべてのファイルを解説しています:https://devblogs.dewiride.com/series/claude-api/ai-lead-qualification-agent-claude-python (新しいタブで開きます)
無料チュートリアルシリーズ
Build an AI Lead Qualification Agent with Claude and Python
作りながら学びたい方へ。ブログの無料ステップガイドで、このプロジェクトの作り方を順を追って紹介しています。
手に入るもの
アーカイブの中身が一目でわかります。
- バージョン 1.0.0 の完全な Python ソースコード
- エンドポイント POST /api/v1/leads/qualify とヘルスチェックを備えた FastAPI アプリ
- Pydantic モデルに基づく Claude の構造化出力
- Python で計算する、優先度と理由付きの透明な 0〜100 スコアカード
- すべてのレスポンスにリクエスト ID が付く明確なエラーレスポンス(422、502、503、504)
- トークン使用量を記録し、顧客データを含まない安全なログ
- 1 つの Markdown ファイルで編集できる、キャッシュされたシステムプロンプト
- Claude API を一切呼び出さない 39 個のオフライン pytest テスト
- テスト済みの正確なパッケージバージョンを記録した uv.lock
- セットアップ、設定、API リファレンス、カスタマイズ方法をまとめた README
- すべての設定項目を含む .env.example テンプレート
使用している技術
開発と動作確認に使った実行環境とバージョンです。
- Python3.14
- FastAPI0.143.0
- Pydantic2.14.1
- Anthropic Python SDK1.13.0
- Uvicorn0.54.0
- pytest9.1.1
アーカイブの中身
展開したあとに手元に残るファイル構成です。
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
- lead_qualifier/
- 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
必要になるもの
動かすために必要なアカウントやサービスです。あとから驚くことはありません。
- uv(Python 3.14 を自動でインストールします)
- クレジットのある Anthropic アカウントの Claude API キー(API 利用料は Anthropic から請求されます)
- ターミナルでコマンドを実行する基本的な知識
- macOS、Windows、または Linux
リリース
これまでのすべてのバージョンを新しい順に並べています。
1.0.0最新
最初のリリースです。リードからの短いメッセージを 1 つの API エンドポイントに送ると、CRM 対応の JSON が返ります:記載された連絡先、意図、優先度とわかりやすい理由付きの 0〜100 のリードスコア、短い要約、返信の提案。明確なエラーレスポンス、リクエスト ID、個人データを含まないログ、Claude API を呼び出さずに実行できる完全なテストスイートも含まれます。
Source Code Licence
利用できる範囲
What you may and may not do with the source code you buy.
ライセンスの全文を読む
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
AI Lead Qualifier
- ₹1,499+GST(お支払い時)
- $29