system-prompts-and-models-o.../salesflow-saas/backend/app/workers/affiliate_tasks.py
Claude 5f3b0b9a20
Migrate SalesMatic to Dealix + Add complete affiliate recruitment & AI sales system
- Rename all SalesMatic references to Dealix (ديل اي اكس) across frontend, backend, configs, and SVG logos
- Add complete automated affiliate recruitment system with:
  - Job posting templates (Arabic/English) with ad variations for social media, LinkedIn, job boards
  - Full onboarding package: welcome guide, company profile, step-by-step guide, FAQ (60+ Q&A), targets & earnings
  - Sales scripts: phone calls, WhatsApp, in-person, email templates, objection handling (15+), closing techniques
  - Targeting guides: social media, AI tools, Google, LinkedIn, local business, referral strategies
  - Legal agreements: freelance contract, employment offer (10+ deals/month auto-hire), commission structure
  - AI chatbot for affiliates: config, knowledge base, conversation flows
- Add professional sector presentations for 10 industries (healthcare, real estate, restaurants, retail, education, beauty, automotive, legal, construction, e-commerce)
- Add Gold Guarantee system (30-day full refund) with terms and conditions
- Add AI Sales Agents system: lead generation, WhatsApp/voice/email outreach, lead scoring, auto-booking
- Add backend: Affiliate & AI Conversation models, API endpoints, Celery worker tasks
- Update landing page with Gold Guarantee, Affiliate CTA, and AI Agents sections

https://claude.ai/code/session_01KnJgK7RwyeCvRZTRThHtfU
2026-03-30 15:49:58 +00:00

90 lines
3.0 KiB
Python

from app.workers.celery_app import celery_app
from datetime import datetime, timezone
import logging
logger = logging.getLogger(__name__)
@celery_app.task(name="app.workers.affiliate_tasks.check_monthly_targets")
def check_monthly_targets():
"""
Check affiliate monthly targets and auto-promote to employed status.
Runs daily at midnight.
Target: 10 deals/month = automatic employment offer.
"""
logger.info("Checking affiliate monthly targets for auto-employment...")
# Implementation: Query all active affiliates
# Check current_month_deals >= 10
# Update status to EMPLOYED
# Send congratulations notification via WhatsApp/Email
# Trigger employment offer generation
@celery_app.task(name="app.workers.affiliate_tasks.calculate_monthly_commissions")
def calculate_monthly_commissions():
"""
Calculate and finalize monthly commissions for all affiliates.
Runs on the 1st of each month.
"""
logger.info("Calculating monthly commissions...")
# Implementation: Aggregate all confirmed deals per affiliate
# Calculate total commissions + bonuses
# Create AffiliatePerformance records
# Reset current_month_deals counters
# Send payment summary to affiliates
@celery_app.task(name="app.workers.affiliate_tasks.send_affiliate_weekly_report")
def send_affiliate_weekly_report():
"""
Send weekly performance report to all active affiliates.
Runs every Sunday at 9 AM Riyadh time.
"""
logger.info("Sending weekly reports to affiliates...")
# Implementation: Compile weekly stats per affiliate
# Leads generated, calls made, deals closed
# Commission earned this week/month
# Ranking among peers
# Motivational message + tips
# Send via WhatsApp
@celery_app.task(name="app.workers.affiliate_tasks.ai_lead_generation_scan")
def ai_lead_generation_scan():
"""
AI agent scans for new potential leads from various sources.
Runs every 6 hours.
"""
logger.info("AI lead generation scan initiated...")
# Implementation: Scrape Google Maps by industry/city
# Search LinkedIn for decision makers
# Check business directories
# Score and qualify leads
# Add to outreach queue
@celery_app.task(name="app.workers.affiliate_tasks.ai_outreach_followup")
def ai_outreach_followup():
"""
AI agent follows up with leads in active conversations.
Runs every 30 minutes.
"""
logger.info("AI outreach follow-up check...")
# Implementation: Check active conversations
# Send follow-ups for conversations with no response > 24h
# Escalate hot leads to human sales reps
# Update sentiment and interest scores
@celery_app.task(name="app.workers.affiliate_tasks.process_auto_bookings")
def process_auto_bookings():
"""
Process and confirm auto-booked meetings.
Runs every 15 minutes.
"""
logger.info("Processing auto-bookings...")
# Implementation: Check new booking requests
# Send calendar invites to sales reps
# Send confirmation to clients via WhatsApp/Email
# Update booking status