Enable WhatsApp-based meal planning and cook coordination via the WhatsApp Cloud API using a production-grade setup connected to Metaβs infrastructure.
Entity | Role |
---|---|
Business Account | Root container for assets (WABA, App, System Users, People, etc.) |
WhatsApp Business Account (WABA) | Holds sender phone numbers and templates |
Phone Number (Sender ID) | Used to send WhatsApp messages via Cloud API |
Meta App | Acts as API client: holds tokens, permissions, and webhooks |
System User | A token issuer for backend API access (non-human, long-lived tokens) |
Message Templates | Pre-approved formats to initiate outbound messages |
Backend Server (FastAPI) | Your code that generates plans, responds to user input, and hits the API |
WhatsApp User (Customer) | Receives messages (residents, cooks, etc.) |
+---------------------------+
| Meta Business Manager |
| (bettermeals.ai account)|
+---------------------------+
|
+--------------------------------------------------+
| |
+----------------------+ +-----------------------------+
| WhatsApp Business | | Meta App |
| Account (WABA) | | (Dev Console β App ID) |
| - Owns sender number | | - Token manager |
| - Hosts templates | | - Webhook receiver config |
+----------------------+ +-----------------------------+
| |
| owns | provides access token
v v
+----------------------+ +------------------------------+
| Phone Number (e.g. | <--- used in ---> | FastAPI Backend Server |
| +91 96066 44030) | | - Calls WhatsApp Cloud API |
| - Has phone_number_id| | - Uses permanent access token|
+----------------------+ | - Handles user & cook flows |
+------------------------------+
|
Sends API message to
|
v
+-----------------------------------------+
| WhatsApp Cloud API Endpoint |
| POST /<phone_number_id>/messages |
+-----------------------------------------+
|
Delivers to
|
v
+---------------------------+
| WhatsApp User (Customer) |
| - Resident, Cook, etc. |
+---------------------------+
-
Saturday Trigger (FastAPI cron job or scheduler)
-
Backend sends template
weekly_plan_prompt
via Cloud API using:phone_number_id
access_token
-
User receives message with link to approve plan
-
Upon approval:
- Backend triggers grocery agent
- Sends payment link via
payment_prompt
template
-
User pays β meal plan confirmed β group instructions initiated
Step | Component | Action |
---|---|---|
1 | Business Manager | Create business account + verify |
2 | WhatsApp Manager | Create WABA, add phone number |
3 | Meta Developer App | Create app, add WhatsApp product |
4 | System User | Generate permanent access token |
5 | Template Library | Create & get approval for templates |
6 | Backend Integration | Store token, send messages via API |
7 | Webhooks (optional) | Capture replies and delivery statuses |
-
Meta App needs the following scopes:
whatsapp_business_messaging
whatsapp_business_management
-
System User should be assigned to:
- WABA (to access phone number)
- Meta App (to issue tokens)
-
Access token must be securely stored in your
.env
or Secrets Manager
Environment | Behavior |
---|---|
Dev Mode | Send messages to 5 test numbers only |
Production | Send to real users with approved templates |
- Token Management: Use system user tokens; rotate on expiration
- Template Naming: Use semantic names (
plan_reminder
,cook_instr
, etc.) - Error Handling: Monitor
message_status
anderrors
via webhooks - Multi-language: Templates must be submitted per locale (e.g.,
en_US
,hi_IN
)