system-prompts-and-models-o.../salesflow-saas/backend/app/integrations/whatsapp.py
Claude f1852c1121
Add SalesMatic AI Sales SaaS Platform - Complete Foundation
Full-stack AI-powered sales automation platform for Saudi SMEs:

Backend (FastAPI + PostgreSQL):
- Multi-tenant architecture with row-level isolation
- JWT auth with RBAC (owner/manager/agent/admin)
- Lead, Customer, Deal, Pipeline, Activity, Message, Proposal models
- Dashboard analytics API (overview, pipeline, revenue)
- WhatsApp Business API, Email (SMTP/SendGrid), SMS (Unifonic) integrations
- Celery + Redis workers for automated follow-ups and scheduled messages
- Property model for Real Estate module (Riyadh districts)
- Hijri date utilities, Arabic/English localization

Frontend (Next.js + Tailwind):
- Professional Arabic RTL landing page with 10 sections
- Brand identity: SalesMatic (سيلزماتك) with custom SVG logo
- Color system: Trust Blue #0F4C81, Growth Teal #00BFA6, CTA Orange #FF6B35
- IBM Plex Sans Arabic + Inter typography
- Responsive design, dark hero section, pricing table, FAQ

Industry Templates:
- Healthcare/Clinics: pipeline stages, WhatsApp message templates, auto-workflows
- Real Estate Riyadh: 20 districts, property tours, payment plans, matching

Infrastructure:
- Docker Compose (PostgreSQL, Redis, Backend, Celery, Frontend, Nginx)
- Nginx reverse proxy config
- Makefile for common operations

https://claude.ai/code/session_01LLR7jzpyNRwDA9kojtT3CW
2026-03-28 03:06:53 +00:00

56 lines
1.8 KiB
Python

import httpx
from app.config import get_settings
settings = get_settings()
WHATSAPP_API_URL = "https://graph.facebook.com/v21.0"
async def send_whatsapp_message(phone: str, message: str) -> dict:
"""Send a text message via WhatsApp Business API."""
if not settings.WHATSAPP_API_TOKEN or not settings.WHATSAPP_PHONE_NUMBER_ID:
return {"status": "error", "detail": "WhatsApp not configured"}
url = f"{WHATSAPP_API_URL}/{settings.WHATSAPP_PHONE_NUMBER_ID}/messages"
headers = {
"Authorization": f"Bearer {settings.WHATSAPP_API_TOKEN}",
"Content-Type": "application/json",
}
payload = {
"messaging_product": "whatsapp",
"to": phone,
"type": "text",
"text": {"body": message},
}
async with httpx.AsyncClient() as client:
response = await client.post(url, json=payload, headers=headers)
return response.json()
async def send_whatsapp_template(phone: str, template_name: str, language: str = "ar", components: list = None) -> dict:
"""Send a template message via WhatsApp Business API."""
if not settings.WHATSAPP_API_TOKEN:
return {"status": "error", "detail": "WhatsApp not configured"}
url = f"{WHATSAPP_API_URL}/{settings.WHATSAPP_PHONE_NUMBER_ID}/messages"
headers = {
"Authorization": f"Bearer {settings.WHATSAPP_API_TOKEN}",
"Content-Type": "application/json",
}
payload = {
"messaging_product": "whatsapp",
"to": phone,
"type": "template",
"template": {
"name": template_name,
"language": {"code": language},
},
}
if components:
payload["template"]["components"] = components
async with httpx.AsyncClient() as client:
response = await client.post(url, json=payload, headers=headers)
return response.json()