system-prompts-and-models-o.../dealix/auto_client_acquisition/targeting_os/free_diagnostic.py
Dealix Builder e106a9a0d2 feat(targeting+service+excellence): Saudi Targeting OS + Service Tower + Service Excellence — 38 modules + 62 endpoints + 105 tests
Targeting & Acquisition OS (16 modules) — نظام الاستهداف الذكي
- account_finder: account-first targeting; 12 buying signals; deterministic 10-25 accounts per (sector, city)
- buyer_role_mapper: 14 buyer roles + sector-specific buying-committee maps + role-based Arabic angles
- contact_source_policy: 12 sources (crm_customer→opt_out) with risk_score, channels-allowed, retention guidance, lawful_basis
- contactability_matrix: 5 action modes (suggest_only/draft_only/approval_required/approved_execute/blocked); opt-out always blocked
- linkedin_strategy: Lead Forms + Ads + manual ONLY; linkedin_do_not_do() locks scrape/auto-DM/auto-connect/extensions
- email_strategy: drafts + unsubscribe footer + domain-pacing (fresh/warmed/trusted/damaged) + spam-trigger risk
- whatsapp_strategy: opt-in only; rejects cold + risky phrases; opt-in template requires explicit purpose+company+unsubscribe
- social_strategy: official APIs only; listening + drafts; no auto-publish
- outreach_scheduler: day-by-day plans + daily limits + opt-out enforcement
- reputation_guard: bounce/complaint/opt-out thresholds → healthy/watch/pause + recovery actions per channel
- daily_autopilot: Arabic brief + 7 today actions + EOD report
- acquisition_scorecard: pipeline + meetings + risks + productivity_score
- self_growth_mode: 5 ICP focuses for Dealix; daily brief + monthly targets
- free_diagnostic: Free Growth Diagnostic (3 ops + msg + risk + plan) → paid pilot recommendation
- contract_drafts: Pilot/DPA/Referral/Agency/SOW outlines (legal_review_required, PDPL-aware)
- service_offers: 7 targeting-tier offers + recommend by customer-type

Service Tower (8 modules) — برج الخدمات الذاتية (12 productized services)
- service_catalog: 12 services with target_customer/outcome/inputs/workflow/deliverables/pricing/risk/proof/upgrade
- service_wizard: deterministic recommend (agency→partner; list→list_intelligence; founder→self_growth; CEO→exec_brief; budget≥2999→growth_os; default→first_10)
- mission_templates: workflow steps with approval gates + linked growth missions
- pricing_engine: SAR quotes scaled by company_size×urgency×channels_count + setup_fee + monthly_offer
- deliverables: client report outline + proof pack template + operator checklist (no live actions)
- service_scorecard: 0..100 score from drafts/replies/meetings/pipeline/CSAT
- whatsapp_ceo_control: daily brief, approval cards (≤3 buttons), risk alerts, EOD reports
- upgrade_paths: deterministic next-service recommendation + Arabic upsell messages

Service Excellence OS (8 modules) — مصنع الخدمات الممتازة
- feature_matrix: 12 must-have features per service + advanced/premium/future tiers
- service_scoring: 10-dimension excellence score (clarity, speed_to_value, automation, compliance, proof, upsell, uniqueness, scalability, ops_daily, proof_data) → launch_ready/beta_only/needs_work
- quality_review: 4 gates (proof / approval / pricing / channels) + status verdict; review_service_before_launch and review/all
- competitor_gap: 7 competitor categories (CRM, WhatsApp tools, email assistants, LinkedIn tools, agencies, revenue intelligence, generic AI) + Dealix advantages + do-not-copy
- proof_metrics: required metrics + ROI estimate (pipeline_x + closed_won_x) + Arabic summary
- research_lab: monthly brief + feature hypotheses + top-3 experiments + monthly review
- service_improvement_backlog: feedback→backlog conversion + impact/effort prioritization + weekly improvements
- launch_package: landing outline + sales script + 12-min demo script + 5-day onboarding checklist

Routers (3 new) — 62 endpoints
- /api/v1/targeting/* — 20 endpoints (accounts, buying-committee, contacts, uploaded-list, outreach, daily-autopilot, self-growth, reputation, linkedin, drafts, free-diagnostic, services, contracts)
- /api/v1/services/* — 20 endpoints (catalog, recommend, intake, start, workflow, deliverables, proof-pack, quote, setup-fee, monthly-offer, scorecard, upgrade-path, ceo daily-brief/approval-card/risk-alert/EOD)
- /api/v1/service-excellence/* — 22 endpoints (feature-matrix, score, quality-review, review/all, proof-metrics, roi-estimate, gap-analysis, research-brief, hypotheses, experiments, monthly-review, backlog, weekly-improvements, launch-package, landing/sales/demo/onboarding)

Tests (3 new files, 105 tests)
- test_targeting_os: 47 tests (Arabic accounts, buying committees, opt-out blocked, cold WA blocked, LinkedIn no-scraping, email unsubscribe, WA risk, outreach plan, reputation guard, self-growth, contracts, scorecard)
- test_service_tower: 38 tests (12+ services, all have pricing/proof/deliverables/approval, wizard recommendations, workflow includes approval, quote scales, CEO cards ≤3 buttons, no live send)
- test_service_excellence: 33 tests (feature matrix, score returns status, ALL services pass quality gates, ROI x-multiples, 7 competitor categories, hypotheses+experiments, backlog conversion, launch package complete, demo=12min)

Docs (3 new + 1 updated)
- TARGETING_ACQUISITION_OS.md (Arabic)
- SERVICE_TOWER_STRATEGY.md (Arabic)
- SERVICE_EXCELLENCE_OS.md (Arabic)
- DEALIX_100_PERCENT_LAUNCH_PLAN.md — added §36 Targeting OS + §37 Service Tower + §38 Service Excellence + §39 Landing Pages

Landing pages (4 new, RTL Arabic)
- services.html — 3 doors + 12 productized services
- free-diagnostic.html — free growth diagnostic
- first-10-opportunities.html — kill feature
- agency-partner.html — agency partner program

Test results
- 105/105 new tests pass
- Full suite: 768 passed, 2 skipped
- 0 existing tests broken

Safety + integration with previous layers
- Targeting OS uses contactability_matrix → ALL contacts gated before any send
- Service Tower's workflow includes approval gate; ALL services live_send_allowed=False
- Service Excellence quality_review BLOCKS launch on missing proof/approval/pricing/unsafe channels
- linkedin_do_not_do() encodes 8 explicit prohibitions (scraping/auto-DM/auto-connect/extensions)
- whatsapp_do_not_do() blocks cold sends + group scraping
- Contracts always: legal_review_required=True, not_legal_advice=True, PDPL sections present
- Self-Growth Mode lets Dealix target its OWN ICP using the same approval-first pipeline

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-01 17:11:00 +03:00

148 lines
5.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""Free Growth Diagnostic — العرض المجاني الذي يجلب pilots."""
from __future__ import annotations
from typing import Any
from .account_finder import recommend_accounts
from .contact_source_policy import classify_source
from .contactability_matrix import evaluate_contactability
def build_free_growth_diagnostic(
company_profile: dict[str, Any],
) -> dict[str, Any]:
"""
Build a free 5-section Arabic growth diagnostic for a prospect.
Inputs: company_profile = {sector, city, offer, goal, has_list?, channels?}
Outputs: 3 opportunities + 1 message + 1 risk + 1 mini proof plan + paid pilot offer.
"""
sector = company_profile.get("sector", "saas")
city = company_profile.get("city", "Riyadh")
offer = company_profile.get("offer", "")
accounts = recommend_accounts(
sector=sector, city=city, offer=offer, goal="diagnostic", limit=3,
)["accounts"]
sample_message = (
f"هلا، لاحظت توسعكم في قطاع {sector}. "
"نشتغل على Dealix كمدير نمو عربي للشركات السعودية. "
"خلال 7 أيام نطلع لكم 10 فرص B2B + رسائل + خطة متابعة. "
"يناسبكم ديمو 12 دقيقة هذا الأسبوع؟"
)
risk_summary = {
"label_ar": "احتمال إضرار سمعة الـdomain أو رقم واتساب",
"why_ar": (
"لو أرسلت لقائمة بدون opt-in، تتجاوز PDPL ويمكن أن تُحظر القناة. "
"الحل: ابدأ بمصادر آمنة فقط."
),
"mitigation_ar": [
"صنّف كل contact حسب المصدر.",
"أوقف أي رقم بدون opt-in.",
"ابدأ بـ Free Diagnostic ثم Pilot.",
],
}
mini_proof = build_mini_proof_plan()
return {
"company_profile": {"sector": sector, "city": city, "offer": offer},
"delivered_at": "draft",
"approval_required": True,
"sections": {
"opportunities_ar": accounts,
"sample_message_ar": sample_message,
"risk_summary_ar": risk_summary,
"mini_proof_plan_ar": mini_proof,
"paid_pilot_offer": recommend_paid_pilot_offer({"sector": sector}),
},
"next_step_ar": (
"إذا أعجبتك العينة، نكمل Pilot 7 أيام بـ499 ريال "
"أو مجاناً مقابل case study بعد انتهاء الـPilot."
),
}
def analyze_uploaded_list_preview(
contacts: list[dict[str, Any]],
) -> dict[str, Any]:
"""
Preview-only analysis of a customer-uploaded list.
Classifies sources + contactability without storing. Returns aggregate.
"""
if not contacts:
return {"total": 0, "by_status": {}, "preview": []}
by_status: dict[str, int] = {"safe": 0, "needs_review": 0, "blocked": 0}
preview: list[dict[str, Any]] = []
for i, c in enumerate(contacts[:20]): # only first 20 for preview
verdict = evaluate_contactability(c)
status = verdict["status"]
by_status[status] = by_status.get(status, 0) + 1
preview.append({
"index": i,
"source": classify_source(c.get("source", "unknown_source"))["source"],
"contactability": status,
"allowed_channels": verdict.get("allowed_channels", []),
})
# Aggregate over the FULL list
full_by_status = dict(by_status)
if len(contacts) > 20:
# Project remaining proportionally — deterministic.
scale = len(contacts) / 20
full_by_status = {k: int(v * scale) for k, v in by_status.items()}
return {
"total": len(contacts),
"by_status": full_by_status,
"preview": preview,
"recommendations_ar": [
"ابدأ بالـsafe contacts فقط في الأسبوع الأول.",
"راجع الـneeds_review يدوياً قبل أي إرسال.",
"تخطّ الـblocked تماماً (opt-out).",
],
}
def recommend_paid_pilot_offer(diagnostic: dict[str, Any]) -> dict[str, Any]:
"""Recommend a paid Pilot offer based on diagnostic context."""
return {
"offer_id": "first_10_opportunities_pilot_7d",
"name_ar": "Pilot 7 أيام: 10 فرص + رسائل + متابعة + Proof Pack",
"price_sar_min": 499,
"price_sar_max": 1500,
"free_alternative_ar": "مجاني مقابل case study بعد انتهاء الـPilot.",
"deliverables_ar": [
"10 فرص B2B مع why-now.",
"10 رسائل عربية جاهزة.",
"خطة متابعة 7 أيام.",
"Proof Pack تفصيلي.",
],
"approval_required": True,
}
def build_mini_proof_plan() -> dict[str, Any]:
"""A small Proof Pack template anyone can run in their head."""
return {
"metrics_to_track": [
"leads_created",
"drafts_approved",
"positive_replies",
"meetings_drafted",
"pipeline_influenced_sar",
"risks_blocked",
],
"how_to_count_ar": (
"كل metric يُحسب يومياً عبر Proof Ledger. "
"في نهاية الأسبوع، نولّد PDF/JSON ونشاركه مع الإدارة."
),
"review_frequency": "weekly",
}