system-prompts-and-models-o.../dealix/docs/CONNECTOR_SETUP_GUIDES.md
Dealix Builder 47f4dc2fb6 feat(positioning+customer-ops): Saudi Revenue Execution OS — 8 modules + 20 endpoints + 44 tests + 8 docs + 2 modes
Locks Dealix's positioning forever and closes the operational gap between
"great product" and "great customer experience": onboarding, connectors,
support SLA, incidents, customer success cadence, and companies/marketers
landing pages.

Positioning Lock (3 docs)
- POSITIONING_LOCK.md (Arabic): Saudi Revenue Execution OS category lock; one-liner; primary buyers (companies + agencies/marketers); wedge (First 10 Opportunities + Proof Pack); 5 approved claims; 5 prohibited categories; 5 modes; 5 bundles; 6 "what Dealix is NOT" rules
- PROHIBITED_CLAIMS.md (Arabic): 8 categories of forbidden marketing language (guaranteed results, scraping, full automation, bypass approvals, competitor attacks, legal/financial promises, medical language, exaggerated speed) + technical enforcement (safety_eval + tone_eval + quality_review_gate + tool_action_planner + test_positioning_lock.py)
- APPROVED_MARKET_MESSAGING.md (Arabic): tagline + 30-second elevator pitch + 5 headlines + competitor positioning table + 4-segment outreach templates + LinkedIn/X social posts + slogan bank

Customer Ops (6 modules)
- onboarding_checklist: 8-step Pilot onboarding (select_goal → select_bundle → company_intake → connect_channels → upload_or_source → risk_review → first_service_run → first_proof_pack) with progress tracking + state advancement
- connector_setup_status: 11 connectors (Gmail/Calendar/Sheets/Moyasar/WhatsApp/Forms/LinkedIn-LeadForms/GBP/CRM/Meet/Instagram) each with default_mode (draft_only/manual/ingest_only/approved_execute), launch phase, and blocking flag; ready_for_first_service gate requires no blocking connectors missing AND ≥1 connected
- support_ticket_router: 4-tier P0/P1/P2/P3 classification with Arabic+English keyword matching; auto-classifies "تسريب", "إرسال بدون موافقة", "بدون موافقتي", "live charge", "unauthorized" as P0; per-priority Arabic first-response templates; SLA targets per priority
- sla_tracker: SLA targets per priority (P0=30min/4h, P1=2h/24h, P2=8h/72h, P3=24h/1week); record_sla_event with strict event-type validation; classify_sla_breach for individual tickets; build_sla_health_report aggregates with verdict (healthy/watch/critical based on breach_rate)
- customer_success_cadence: 6 cadence types (weekly_check_in, monthly_proof_review, QBR, at_risk_alert, renewal_30/7_day); build_at_risk_alert with risk_score 0..100 from days_inactive + drafts_pending + last_proof_pack_days_ago; build_customer_success_plan with 30-day per-bundle cadences (growth_starter, executive_growth_os, partnership_growth)
- incident_router: SEV1/SEV2/SEV3 with first_action_minutes + comm_cadence; auto-SEV1 on has_data_leak OR has_unauthorized_send; SEV2 on affected_customers≥5; canonical 5-step response plan (freeze live actions / notify founder / create incident channel / review Action Ledger / PDPL 72h notification) + per-severity additional steps + post-mortem template

New Operator Modes (2)
- self_growth_mode: re-exports targeting_os.self_growth_mode (DEALIX_ICP_FOCUSES, recommend_dealix_targets, build_self_growth_daily_brief, build_weekly_learning_report) + operator-tier reminders (no cold WhatsApp even for Dealix itself, all drafts approval-first, no scraping)
- service_delivery_mode: orchestrates service_tower workflow + revenue_launch.pilot_delivery + customer_ops.sla_tracker; build_service_delivery_brief (per-service template), build_sla_status_for_delivery (breach detection on open tickets), build_post_delivery_handoff (5-step transition to Customer Success cadence)

Router (1 new) — 20 endpoints
- /api/v1/customer-ops/* — onboarding (checklist/update-step/demo), connectors (catalog/summary/update/demo), support (priorities/classify/route/first-response), sla (event/classify-breach/health-report/health-report-demo), incidents (triage/response-plan), cs (weekly-check-in/at-risk-alert/success-plan)

Customer-facing pages (1 new, 1 already-existed-preserved)
- landing/companies.html (NEW): Saudi B2B companies pitch — Approval-first, no scraping, no cold WhatsApp; 4 bundles (Growth Starter / Data to Revenue / Executive Growth OS / Full Growth Control Tower); Proof Pack section; safety + compliance section
- landing/marketers.html (existed): preserved as-is — agency/marketers Agency Growth OS path

Tests (2 new files, 44 tests)
- test_customer_ops.py: 31 tests
  * 4 onboarding (8 steps, advancement, unknown step error, complete-all)
  * 5 connectors (critical connectors present, blocking_missing detection, ready gate, validation, write)
  * 8 support (P0 security, P0 unauthorized send, P1 service down, P2 connector, P3 default, empty input, route includes SLA, P0 first-response Arabic with 30 min)
  * 6 SLA (event validates, log appends, breach detection within/exceeded targets, health report aggregation, critical verdict)
  * 4 incidents (data leak SEV1, unauthorized send SEV1, ≥5 customers SEV2, single customer SEV3, SEV1 plan includes PDPL)
  * 4 customer success (weekly check-in talking points Arabic, at-risk high severity, at-risk low severity, success plan per bundle including growth_starter and executive_growth_os Founder Shadow Board)

- test_positioning_lock.py: 13 tests
  * positioning_lock.md exists with category + "ليس CRM" + "ليس بوت"
  * prohibited_claims.md exists with "نضمن" + "scraping"
  * approved_market_messaging.md has Approval-first + PDPL + Saudi Tone + Proof Pack
  * landing pages contain NO positive forbidden claims (negative restatements like "no auto-DM" in safety sections allowed)
  * companies.html includes "Approval-first" + "Proof Pack"
  * agency-partner.html OR marketers.html exists
  * private-beta.html does NOT promise guarantees
  * REVENUE_TODAY_PLAYBOOK emphasizes Approval-first
  * positioning_lock lists all 5 bundles
  * positioning_lock lists all 5 modes (CEO + Growth Manager + Agency Partner + Self-Growth + Service Delivery)

Customer Ops Docs (5 new)
- ONBOARDING_RUNBOOK.md (Arabic): 8 onboarding steps + day-by-day Day1-Day5 + 11 connector states + acceptance criteria
- SUPPORT_SLA.md (Arabic): 4 priority tiers + auto-classification keywords + Arabic first-response templates + weekly review process
- INCIDENT_RESPONSE.md (Arabic): SEV1/SEV2/SEV3 logic + canonical response plan + per-severity additional steps + post-mortem template + Arabic communication templates + auto-actions
- CUSTOMER_SUCCESS_PLAYBOOK.md (Arabic): cadence types + weekly agenda (25 min) + at-risk scoring formula + per-bundle cadence + QBR + renewal flow + health score formula
- CONNECTOR_SETUP_GUIDES.md (Arabic): all 11 connectors with scopes + step-by-step + acceptance criteria + troubleshooting table

Test results
- 44/44 new tests pass
- Full suite: 949 passed, 2 skipped (missing API keys, unrelated)
- 0 existing tests broken

Safety + integration
- All 20 customer-ops endpoints: approval_required=True, live_send_allowed=False
- support_ticket_router HARD-CLASSIFIES "تسريب", "إرسال بدون موافقة", "live charge", "unauthorized" as P0 (founder owner, 30-min first response)
- incident_router auto-promotes to SEV1 on has_data_leak or has_unauthorized_send (regardless of affected_customers count)
- onboarding_checklist requires WhatsApp connector (blocking) before ready_for_first_service
- connector_setup_status default_mode is draft_only/manual/ingest_only — never live
- Positioning Lock test_positioning_lock.py enforces:
  * 5 bundles must be listed in POSITIONING_LOCK.md
  * 5 modes must be listed
  * landing pages must not contain positive forbidden claims (8 phrases)
  * companies.html must mention Approval-first + Proof Pack
- self_growth_mode reminds operator: no cold WhatsApp even for Dealix itself
- service_delivery_mode integrates SLA tracker before declaring delivery success

Integration with everything before
- Customer Ops onboarding integrates Service Bundles (autonomous_service_operator.service_bundles)
- Customer Ops connectors mirror connector_catalog risk_levels + add operational state machine
- Support classifier integrates with security_curator (P0 on secret leaks) + revenue_launch.payment_manual_flow (P0 on unauthorized charge)
- Customer Success metrics flow from agent_observability + revenue_launch.proof_pack_template
- Service Delivery Mode wires service_tower.workflow + revenue_launch.pilot_delivery + sla_tracker into one pipeline
- Self-Growth Mode wraps targeting_os.self_growth_mode with operator-tier safety reminders
- Companies + Marketers pages enforce POSITIONING_LOCK headlines

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

205 lines
5.6 KiB
Markdown

# Connector Setup Guides
> دليل مرجعي لربط كل قناة. **القاعدة:** `draft_only` افتراضياً. لا live action قبل env flag صريح + اعتماد بشري.
---
## 11 Connectors المدعومة
| Key | Default Mode | Phase | Blocking للـ first service |
|-----|--------------|------:|--------------------------|
| gmail | draft_only | 1 | لا |
| google_calendar | draft_only | 1 | لا |
| google_sheets | approved_execute | 1 | لا |
| moyasar | manual | 1 | لا |
| whatsapp_cloud | draft_only | 1 | **نعم** |
| website_forms | approved_execute | 1 | لا |
| linkedin_lead_forms | ingest_only | 2 | لا |
| google_business_profile | draft_only | 2 | لا |
| crm_generic | draft_only | 2 | لا |
| google_meet | ingest_only | 2 | لا |
| instagram_graph | ingest_only | 3 | لا |
---
## 1. Gmail (drafts فقط افتراضياً)
**Scopes المطلوبة:**
- `gmail.compose` (لإنشاء drafts)
- `gmail.modify` (لإدارة الـ labels — read-only labels فقط في Phase 1)
**خطوات:**
1. Google Cloud Console → Create OAuth client.
2. أضف Dealix كـ application authorized.
3. منح الصلاحيات على scopes أعلاه فقط.
4. Dealix يستلم refresh_token + access_token.
5. وضع التشغيل: `connected_draft_only`.
**Live send:** يتطلب `GMAIL_ALLOW_LIVE_SEND=true` env + اعتماد بشري للرسالة.
---
## 2. Google Calendar (drafts فقط)
**Scopes:**
- `calendar.events` (drafts only)
**خطوات:**
1. نفس OAuth client من Gmail.
2. أضف scope الـ calendar.
3. Dealix يبني draft events.
4. لا insert إلا بعد:
- `CALENDAR_ALLOW_LIVE_INSERT=true`
- اعتماد بشري لكل event.
---
## 3. Google Sheets (read + append بموافقة)
**Scopes:**
- `sheets.readonly` للقراءة
- `sheets` للكتابة (append فقط)
**خطوات:**
1. نفس OAuth.
2. حدد الـ Spreadsheet ID المستخدم لـ Pilot.
3. Dealix يقرأ leads + يكتب Proof Pack.
**Live append:** يحتاج اعتماد للحقول الحساسة. لا overwrite تلقائي.
---
## 4. Moyasar (manual فقط في Phase 1)
**عملية الإعداد:**
1. حساب Moyasar dashboard.
2. **لا** إدخال API keys في Dealix.
3. عند طلب دفع:
- Dealix يولّد invoice instructions (halalas-correct).
- المؤسس يدخل Moyasar manually + ينشئ invoice.
- يضع invoice URL في Dealix.
4. تأكيد paid: يدوي عبر Moyasar dashboard ثم تحديث pipeline_tracker.
**Phase 2:** ربط API + auto-invoice (مع env flag + audit).
---
## 5. WhatsApp Cloud (Blocking — drafts فقط)
**هذا أهم connector.** بدون WhatsApp opt-in audit، Dealix لا يفعّل first service.
**خطوات:**
1. Meta Developer Account → WhatsApp Business Cloud.
2. Phone number verification.
3. Webhook URL = Dealix endpoint.
4. **مهم:** opt-in audit أولاً عبر `whatsapp_strategy.requires_opt_in`.
**Live send:** يتطلب:
- `WHATSAPP_ALLOW_LIVE_SEND=true`
- opt-in موثّق لكل رقم.
- اعتماد بشري للرسالة.
- موافقة العميل على template.
---
## 6. Website Forms (آمنة)
**خطوات:**
1. أضف form على موقع العميل.
2. Webhook URL = Dealix endpoint.
3. كل form submission يدخل كـ `form.submitted` event.
4. Dealix يبني opportunity card تلقائياً.
**Live send:** auto-acknowledgment email/WhatsApp مسموح بعد opt-in في الـ form.
---
## 7. LinkedIn Lead Gen Forms (Phase 2)
**القاعدة:** lead forms فقط — **لا scraping** ولا auto-DM.
**خطوات:**
1. LinkedIn Campaign Manager → Lead Gen Form.
2. Hidden fields: `campaign_name`, `sector`, `sales_owner`.
3. Webhook إلى Dealix.
4. كل lead → `linkedin_lead_form` source = safe.
---
## 8. Google Business Profile (Phase 2)
**Scopes:**
- `business.manage`
- `reviews.read`
**خطوات:**
1. ربط GBP location.
2. Dealix يقرأ reviews.
3. يبني draft reply لكل review.
4. **Live publish** يحتاج اعتماد + `GBP_ALLOW_LIVE_REPLY=true`.
---
## 9. CRM Generic (Phase 2)
**Supported:** HubSpot, Salesforce, Zoho, Close.
**خطوات:**
1. OAuth حسب الـ CRM.
2. Read-only في الأسبوع الأول.
3. Write مع approval بعد الأسبوع الأول.
4. لا overwrite owner تلقائي.
---
## 10. Google Meet (Phase 2)
**Scopes:**
- `meetings.space.readonly`
- `conferenceRecords.transcripts.readonly`
**خطوات:**
1. OAuth.
2. ingest transcripts بعد موافقة كل المشاركين.
3. Dealix يستخرج objections + next steps + buyer intent.
4. **لا** real-time listening في Phase 2.
---
## 11. Instagram Graph (Phase 3)
**Phase 3 connector.** ingest only لـ comments + DMs + insights.
---
## Acceptance Criteria للـ connector
كل connector يُعتبر مُعدّ بنجاح إذا:
1. State = `connected_draft_only` أو `connected_approved_execute`.
2. Test successful (Dealix قرأ شيء أو كتب draft).
3. لا secrets exposed في الـ logs/traces.
4. Audit entry في Action Ledger.
---
## Troubleshooting
| مشكلة | الحل |
|------|------|
| OAuth callback failed | recheck redirect_uri في Google/Meta console |
| WhatsApp Webhook 401 | تحقق من verify_token |
| Moyasar invoice URL لم يصل | تحقق من dashboard email settings |
| Sheets quota exceeded | خفض الـ append rate أو ربط second Sheet |
| Calendar conflicts | استخدم `freebusy.query` قبل draft event |
---
## Endpoints
```
GET /api/v1/customer-ops/connectors/catalog
POST /api/v1/customer-ops/connectors/summary
POST /api/v1/customer-ops/connectors/update
GET /api/v1/customer-ops/connectors/demo
```