1: phloWA overview
phloWA is the WhatsApp layer of the Phlo platform. It lets a Phlo app send and receive WhatsApp messages through a small gateway, while your application code stays ordinary Phlo: a route to receive, the WhatsApp resource to send.
1.1: The gateway model
phloWA runs a gateway process (built on whatsapp-web.js) for each WhatsApp number. The gateway owns the connection to WhatsApp and exposes a small, secret-gated HTTP API on localhost. Your Phlo app never talks to WhatsApp directly; it talks to the gateway.
- One process per number, linked once by scanning a QR code.
- Inbound: the gateway POSTs each incoming message to a webhook route in your app.
- Outbound: your app calls the gateway's HTTP API through the
WhatsAppresource.
This split keeps the long-lived, stateful WhatsApp session out of your request cycle. Your app stays stateless and short-lived; the gateway holds the session.
1.2: The two directions
| Direction | You write | Carries |
|---|---|---|
| Receive | a POST route, secret-checked |
inbound messages |
| Send | %WhatsApp(url, secret)->... |
text, media, polls, locations |
1.3: What you wire
- The
WhatsAppresource (it requiresHTTP). security/credsso the gateway URL and secret come fromdata/creds.inior the environment, never from code.- A webhook route for inbound messages.
The phlo-demo-whatsapp repository is a complete, credential-shielded reference for both directions. With no credentials it stays inert, so it is safe to run anywhere.