Skip to content

WhatsApp Cloud Integration

Status: Shipped 1.3.0 — billable Marketplace module whatsapp-cloud.

Includes: Meta WABA/phone connect, text + media send/receive, shared inbox, Lead soft link, Meta Cloud template sync + outside-24h enforcement, opt-in WhatsApp Lead Source Driver, Automation whatsapp.message_received / send_whatsapp_template. Deferred: interactive buttons/lists, alternate BSPs.

Follow the Module Architecture, Module Development Standard, Documentation Governance same-PR rule, and the frozen Notification Architecture Contract.


Purpose

Evolve EloSync from a manual WhatsApp handoff (wa.me) into a complete WhatsApp communication platform built on the official WhatsApp Cloud API, while keeping business logic inside EloSync and provider specifics inside replaceable drivers.

Shipped through 1.3.0:

  • Connect tenant WhatsApp Business Accounts and phone numbers via Meta
  • Send and receive text and media through EloSync (not the user’s personal WhatsApp client)
  • Shared inbox, Meta Cloud templates, delivery/read status webhooks
  • Soft-link conversations to Leads; mirror messages on the Lead timeline
  • Opt-in WhatsApp Lead Source Driver (auto_create_leads, default off)
  • Automation trigger whatsapp.message_received and action send_whatsapp_template
  • Notifications for inbound / send failed / needs reauth

Still deferred:

  • Interactive buttons / lists, alternate BSPs, AI WhatsApp features
  • Replacing Communication Templates’ wa.me (kept as fallback when Cloud is not ready)
  • Making WhatsApp the only messaging channel forever (drivers must stay replaceable)

Current state

WhatsApp Cloud (whatsapp-cloud) — shipped 1.3.0

ShippedBehavior
Marketplace moduleBillable CRM slug whatsapp-cloud ($29 / $290)
ConnectMeta OAuth → WABA → phone; webhook subscribe; encrypted tokens
InboxShared conversation list + thread; text + media send/receive
TemplatesSync Meta Cloud templates; required outside the 24h window
Lead soft linkManual lead_id; timeline via Lead APIs
Lead SourceOpt-in auto_create_leads + default_lead_source
AutomationSoft dep: whatsapp.message_received / send_whatsapp_template
NotificationsInbound, send failed, needs reauth

Canonical user docs: WhatsApp Cloud · API · Deploy.

Communication Templates fallback (wa.me)

EloSync also supports a lightweight WhatsApp handoff via Communication Templates:

FallbackBehavior
WhatsApp button on Lead pagesShown when Communication Templates is installed and Cloud is not ready / not entitled
Opens wa.me / WhatsApp Desktop / WhatsApp WebAPI returns wa_me_url; the browser opens it
User manually sends messagesThe agent completes send inside WhatsApp; EloSync does not transmit the message

Deferred

CapabilityStatus
Interactive buttons / lists⬜ Deferred
Alternate BSPs (Twilio / 360dialog)⬜ Deferred
AI Features⬜ Deferred

Post-MVP polish (shipped)

CapabilityStatus
Media upload/download✅ Shipped (1.3.0)
Automation WhatsApp triggers/actions✅ Shipped (1.2.0 / automation 1.1.0)
WhatsApp Lead Source Driver (auto-create Leads)✅ Shipped (opt-in auto_create_leads)

Vision

EloSync should become a complete WhatsApp communication platform on the official WhatsApp Cloud API.

Future capabilities include:

  • Connect WhatsApp Business Account
  • Multiple phone numbers
  • Multiple business accounts
  • Send messages
  • Receive messages
  • Message templates (Meta-approved Cloud API templates)
  • Media support
  • Contact synchronization
  • Conversation history
  • Shared inbox
  • Team assignment
  • Internal notes
  • Automation
  • Campaign messaging
  • Activity timeline
  • Notifications

The existing wa.me flow remains a valid fallback until Cloud API connect + send is production-ready for a tenant.


Architecture

Outgoing (high level)

text
Lead

Conversation

Messaging Service

WhatsApp Driver

WhatsApp Cloud API

Meta

Incoming (high level)

text
Meta Webhook

Webhook Verification

WhatsApp Driver

Conversation Service

Lead Activity

Notifications

Automation

Component map (planned)

ComponentResponsibility
Messaging ServiceProvider-agnostic send/receive orchestration, queueing, retries
Conversation ServiceThread lifecycle, assignment, inbox queries, link to Lead
WhatsAppCloudDriverCloud API auth, webhooks, templates, media, status mapping
Lead moduleLead ownership, timeline/activity hooks via LeadService / activity services — not Graph parsing
Notification systemIn-app / mail digests per Notification Architecture Contract
Automation EngineDomain-event workflows (automation module); WhatsApp whatsapp.message_received + send_whatsapp_template shipped in automation 1.1.0 / WA 1.2.0

Business rules (who may send, assignment, logging, automation) stay in EloSync. Drivers only speak to external providers.


Driver architecture

WhatsApp follows the platform driver pattern (same Open/Closed idea as payment gateways, email drivers, and Lead Source Driver Architecture).

Messaging provider driver

Future primary driver:

WhatsAppCloudDriver

Messaging providers should be replaceable. Conversation Service and Messaging Service depend on a messaging-driver contract — not on Meta SDK types leaking into controllers or Lead models.

Future messaging driverRole
WhatsApp CloudOfficial Meta Cloud API (primary)
Twilio WhatsAppAlternate BSP / Twilio channel
360dialogBSP adapter
InfobipBSP adapter
MessageBirdBSP adapter

Drivers only communicate with external providers. They must not own assignment, inbox permissions, Lead business rules, or notification fan-out.

Inbound WhatsApp can also create or enrich leads (e.g. first message from an unknown number). That path uses the Lead Source Driver Architecture catalog entry WhatsApp DriverNormalizedLeadDataLeadDuplicateServiceLeadService.

ConcernDriver family
Send/receive messages, status, mediaMessaging drivers (WhatsAppCloudDriver, …)
Turn an inbound contact into a LeadLead Source Driver (WhatsApp)

Do not collapse both into a single class that writes Leads and messages directly.


Authentication

Documented Meta / OAuth-style onboarding (planned):

text
Tenant

Connect Meta

Select Business

Select WhatsApp Business Account

Select Phone Number

Store encrypted tokens

Subscribe Webhooks

Ready
OperationBehavior
ReconnectRe-run OAuth; refresh tokens; re-select WABA / phone if needed; re-subscribe webhooks; mark healthy
DisconnectUnsubscribe webhooks where possible; clear encrypted tokens; leave historical conversations/messages intact
Token refreshRefresh before expiry; on failure mark needs_reauth and pause outbound/inbound processing for that number

Central holds the platform Meta App configuration. Each tenant owns its own connection, WABA selection, phone numbers, and encrypted secrets (same secret-handling patterns as payment / mail / Meta Lead Ads).


Multi-tenant design

Each tenant owns:

Tenant-owned assetNotes
Meta connectionOAuth / embedded signup linkage
Business AccountSelected Meta Business / WABA
Phone numbersOne or more WhatsApp Business phone numbers
TemplatesSynced Meta message templates for that WABA
TokensEncrypted access tokens / secrets
Webhook subscriptionsPer-number or app-level subscription state scoped to the tenant

No tenant data may be shared. Shared webhook ingress must resolve the tenant by phone number ID / WABA identifier (or equivalent Meta routing key) before Conversation Service runs. Enforce uniqueness of phone number ID → tenant at connect time.


Messaging flow

Outgoing

text
Lead

Compose Message

Conversation Service

WhatsApp Driver

Meta API

Customer

Incoming

text
Customer

Meta Webhook

Driver

Conversation Service

Lead Timeline

Notification

Automation

Sequence (conceptual)


Conversation model

Conceptual entities only — not a finalized schema.

EntityIntent
ConversationsThread between a tenant phone number and a customer WhatsApp identity
MessagesIndividual inbound/outbound items with type, body, status, timestamps
AttachmentsMedia references (prefer encrypted / storage refs; avoid unbounded blob storage in DB)
ParticipantsCustomer + tenant agents involved
StatusesQueued → sent → delivered → read / failed / expired
AssignmentsWhich agent/team owns the conversation
Internal NotesAgent-only notes not sent to WhatsApp
Conversation LabelsTags for inbox filtering and routing

Exact table names, UUIDs, and indexes are deferred to the implementation PR. Prefer linking conversation.lead_id (nullable) rather than duplicating Lead contact fields.


Message types

Support roadmap:

TypeNotes
TextDefault body
ImageMedia download/upload via driver
VideoMedia
AudioMedia / voice notes
DocumentFiles
StickerStickers
LocationLat/long + optional name
ContactsShared contact cards
Interactive ButtonsReply buttons
ListsList messages
Template MessagesMeta-approved templates outside the 24h session window

Drivers map provider payloads into a common internal message type enum; UI and Conversation Service consume the common type.


Message status

Future support for delivery lifecycle:

StatusMeaning
QueuedAccepted by EloSync; not yet accepted by Meta
SentAccepted by Cloud API
DeliveredDelivered to customer device
ReadRead receipt (when available)
FailedPermanent or terminal failure
ExpiredExpired per Meta / session rules

Status webhooks update the Message entity idempotently (by Meta message ID). Drivers translate provider statuses; Conversation Service persists them.


Lead integration

Every conversation should be linked to a Lead whenever possible (match by phone / prior thread / explicit agent link).

Messages should automatically appear inside:

  • Lead Timeline
  • Activities
  • Future Communication History
RuleDetail
Write pathLead activity / timeline updates go through Lead-owned services — not raw inserts from the WhatsApp driver
Unknown numbersMay create or attach a Lead via the WhatsApp Lead Source Driver + LeadService
IndependenceMessaging can exist without Meta Lead Ads; Lead Ads can exist without WhatsApp Cloud

Templates

Two template concepts must stay distinct:

KindToday / future
Communication Templates (shipped)Tenant plain-text snippets for wa.me handoff
WhatsApp Cloud templates (future)Meta-approved templates synced from WABA

Future Cloud template support:

  • Sync Meta templates into the tenant
  • Approval status (pending / approved / rejected)
  • Languages
  • Variables / placeholders
  • Categories (utility, marketing, authentication — per Meta rules)

Sending outside the customer service window requires an approved Cloud template. Communication Templates may later feed copy into Cloud template variables, but they are not the same store.


Automation

Future examples for WhatsApp message triggers (CRM domain-event Automation ships as Marketplace module automation; message events wait on Cloud API):

  • Send welcome message
  • Follow-up reminders
  • Missed appointment reminder
  • Payment reminder
  • Birthday greeting
  • Drip campaigns
  • Workflow automation (if message received → create Task / change Lead stage)

Automations subscribe to Conversation / Message domain events. Drivers do not embed business workflows. See Automation developer guide.


Notifications

Future notifications include:

  • New incoming message
  • Unread conversations
  • Failed delivery
  • Template rejection

Integrate with the existing notification system (Notification Architecture Contract): additive type / metadata / source fields; Reverb fan-out where broadcast_ready; no parallel notification framework.


Security

ControlRequirement
Webhook signature verificationVerify Meta/X-Hub-Signature-256 (or current Meta WhatsApp signature scheme) before trusted processing
Encrypted tokensWABA / phone tokens encrypted at rest; APIs return masks only
Encrypted media referencesStore storage keys / signed URLs carefully; do not log raw media binaries
Queue processingAcknowledge webhooks quickly; process on a dedicated queue
Rate limitingThrottle outbound Cloud API calls; respect Meta rate limits
Idempotent webhook handlingDeduplicate by Meta message / status IDs
Audit loggingPlatform audit for connect/disconnect, send failures, permission changes
Permission checksTenant RBAC for inbox, send, manage connection, manage templates

CSRF-exempt webhook route under a narrow prefix (same operational pattern as payment / email / Meta Lead Ads webhooks).


Error handling

ScenarioExpected behavior
Expired tokensMark connection needs_reauth; pause send/receive for affected numbers; alert tenant admins
Revoked permissionsSame as expired tokens; surface which scope failed
Deleted phone numbersMark number unhealthy; stop routing; keep history
Rate limitingBack off; queue outbound; surface soft errors to agents
Webhook retriesIdempotent processing; prefer 2xx after durable claim
Duplicate webhooksNo duplicate Message rows
Temporary Meta outagesRetry with backoff; dead-letter after exhaustion
Dead-letter queuesOperator visibility + manual replay
Retry strategyExponential backoff; distinguish transient vs permanent Graph errors

Permissions (Meta platform)

Future production requirements (Meta side):

  • Business Verification
  • App Review
  • WhatsApp Business Account
  • Phone Number verification
  • Appropriate WhatsApp Cloud API permissions / products enabled on the Meta App

Local development may use Meta test numbers / development mode without full public Live Mode access. Document tunnel + webhook verify token setup at implementation time.

Tenant RBAC permissions (EloSync side) are TBD at implementation (e.g. inbox view/send, connection manage) and must follow module: + can: conventions.


Future enhancements

Placeholders after core Cloud send/receive and inbox:

EnhancementIntent
AI auto repliesOptional AI responses
AI message summariesThread summaries for agents
Suggested repliesAgent assist
Sentiment analysisConversation scoring
Voice transcriptionVoice notes → text
Conversation analyticsVolume, response time, outcomes
Broadcast campaignsOpt-in bulk messaging within Meta rules
Chatbot builderVisual flows on top of Conversation Service
Multi-agent inboxConcurrent agents, presence
Team workload balancingAssignment algorithms
CRM triggersStage/status changes from message events
Calendar integrationBook from chat (Meetings dependency when relevant)
Task creation from messagesCreate Tasks from a thread
Voice notes transcriptionSame as voice transcription track

AI features remain optional integrations per Module Dependencies.


Relationship with Meta Lead Ads

Meta Lead Ads and WhatsApp Cloud are complementary, not substitutes.

text
Meta Lead Ads

Lead

Lead Service

Conversation

WhatsApp Cloud
IntegrationJob
Meta Lead AdsIngest form submissions → Lead (MetaLeadAdsDriver + Lead Source pipeline)
WhatsApp CloudCommunicate with the customer on WhatsApp (WhatsAppCloudDriver + Conversation Service)

Lead generation and customer communication remain independent modules/capabilities connected through the Lead entity. Either can ship without the other. Shared Meta App configuration may be reused at the platform level, but tenant Page tokens (Lead Ads) and WABA/phone tokens (WhatsApp) stay separate connection records.

Both respect driver boundaries: no Meta parsing inside LeadService; no conversation business rules inside Graph clients.


Relationship with Lead Source Driver Architecture

  • Messaging: WhatsAppCloudDriver (messaging provider contract).
  • Optional lead capture from WhatsApp: catalog WhatsApp Driver under Lead Source Driver Architecture.
  • Never bypass LeadService when creating leads from WhatsApp.

Implementation checklist (MVP delivered)

Backend

  • [x] Central Meta App settings for WhatsApp Cloud (encrypted secrets, verify token)
  • [x] Tenant connect / reconnect / disconnect + encrypted WABA/phone tokens
  • [x] WhatsAppCloudDriver + messaging driver registry
  • [x] Webhook verify + signature rejection path + tenant resolution by phone/WABA id
  • [x] Conversation / Message migrations + services
  • [x] Outbound send queue + inbound process queue + idempotency
  • [x] Lead timeline / activity integration via Lead-owned services
  • [x] Template sync from Meta + outside-24h enforcement
  • [x] Notification types for inbound / failed / needs_reauth
  • [x] Pest: signature, tenancy, idempotency, no direct Lead DB writes from driver

Frontend

  • [x] Connection wizard (Business → WABA → phone)
  • [x] Shared inbox + Lead soft-link entry
  • [x] Compose send + template picker (Cloud templates)
  • [x] Playwright smokes with mocked Cloud API

Docs / ops

  • [x] Flip this page from Planned → shipped sections
  • [x] User Guide + Deployment webhook/env notes
  • [x] CHANGELOG + Product Roadmap status

Implementation status

Shipped MVP 1.0.0

CapabilityStatus
Open WhatsApp manually (wa.me / Desktop / Web)✅ Shipped (Communication Templates fallback)
Cloud API connect + text send/receive✅ Shipped
Incoming messages✅ Shipped
Shared Inbox✅ Shipped
Templates (Meta Cloud)✅ Shipped
Conversation History✅ Shipped
Delivery Tracking / Read Receipts✅ Shipped (webhook statuses)
Soft Lead link + timeline✅ Shipped
WhatsApp Lead Source Driver (opt-in auto-create)✅ Shipped (1.1.0)
Automation WhatsApp triggers / send template✅ Shipped (1.2.0)
Media (image / document / audio / video)✅ Shipped (1.3.0)

Deferred

CapabilityStatus
Interactive buttons / lists⬜ Deferred
AI Features⬜ Deferred
Alternate BSPs⬜ Deferred

Official documentation for the EloSync SaaS Platform.