CRM de WhatsApp, Instagram, Messenger y TikTok de Wachato, basado en Vocero CRM (MIT), listo para desplegar un negocio por instancia: - Marca blanca: nombre, color, moneda y giro del negocio desde el .env (BRAND_NAME, BRAND_ACCENT, BRAND_CURRENCY, BUSINESS_DESCRIPTION); se aplican una vez y luego manda Ajustes → Marca. - Superadmin sembrado al arrancar (SUPERADMIN_*), idempotente. - Servicios y precios, campos personalizados, exportación a Excel/PDF, respaldos, agenda, atribución de anuncios y transcripción de notas de voz. - Diseño con contraste AAA, tema claro y oscuro. - Despliegue: docker compose (Caddy opcional), plantillas para paneles con reverse proxy (deploy/aapanel), imagen publicada en GHCR por la CI. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
105 lines
1.7 KiB
Markdown
105 lines
1.7 KiB
Markdown
# Backend API blueprint
|
|
|
|
Use this reference when the user wants concrete backend responsibilities and route design.
|
|
|
|
## Recommended routes
|
|
|
|
### 1. Code exchange endpoint
|
|
|
|
Example:
|
|
|
|
```text
|
|
POST /api/whatsapp/exchange-token
|
|
```
|
|
|
|
Input:
|
|
|
|
- `code`
|
|
- `waba_id`
|
|
- `phone_number_id`
|
|
|
|
Responsibilities:
|
|
|
|
- validate the request,
|
|
- exchange the code with Meta,
|
|
- fetch connected phone metadata,
|
|
- persist the active connection,
|
|
- optionally store `meta_user_id`.
|
|
|
|
## 2. WhatsApp webhook
|
|
|
|
Example:
|
|
|
|
```text
|
|
GET /api/whatsapp/webhook
|
|
POST /api/whatsapp/webhook
|
|
```
|
|
|
|
GET responsibilities:
|
|
|
|
- verify `hub.verify_token`,
|
|
- return `hub.challenge`.
|
|
|
|
POST responsibilities:
|
|
|
|
- parse each `entry`,
|
|
- parse each `change`,
|
|
- process `value.statuses`,
|
|
- process `value.messages`,
|
|
- upsert by `message_id`.
|
|
|
|
## 3. Send template message
|
|
|
|
Example:
|
|
|
|
```text
|
|
POST /api/whatsapp/send-template
|
|
```
|
|
|
|
Input:
|
|
|
|
- recipient phone
|
|
- approved template name
|
|
- language code
|
|
- template parameters
|
|
|
|
Responsibilities:
|
|
|
|
- normalize the phone,
|
|
- send the message through Meta,
|
|
- store an initial outbound event as `accepted`.
|
|
|
|
## 4. Send freeform text message
|
|
|
|
Example:
|
|
|
|
```text
|
|
POST /api/whatsapp/send-text
|
|
```
|
|
|
|
Use this only for open customer service windows.
|
|
|
|
## 5. Deauthorize callback
|
|
|
|
Example:
|
|
|
|
```text
|
|
GET /api/meta/deauthorize
|
|
POST /api/meta/deauthorize
|
|
```
|
|
|
|
Responsibilities:
|
|
|
|
- read `signed_request`,
|
|
- validate it with `HMAC-SHA256` and the app secret,
|
|
- extract the Meta user identifier,
|
|
- map it to the local user,
|
|
- purge or unlink WhatsApp data,
|
|
- return a confirmation payload.
|
|
|
|
## Important behavior
|
|
|
|
- Store only metadata and tokens server-side.
|
|
- Never trust the UI as source of truth for message delivery.
|
|
- Use idempotent writes for webhook processing.
|