Campaigns let you send a WhatsApp template message to a large audience at once. Each campaign targets a defined audience (contacts, CSV upload, or a custom queryset), maps template variables to audience fields, and tracks delivery, read, and failure counts in real time.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/rahul-baberwal/django-meta-whatsapp/llms.txt
Use this file to discover all available pages before exploring further.
WhatsAppCampaign model fields
| Field | Type | Description |
|---|---|---|
account | FK → WhatsAppAccount | The WhatsApp account used to send this campaign |
name | CharField | Human-readable campaign name |
template | FK → WhatsAppTemplate | The approved template to send (must have status="APPROVED") |
audience_type | CharField | "contacts", "csv", or a named key from WHATSAPP["AUDIENCES"] in settings |
audience_filters | JSONField | Extra ORM filter kwargs applied when audience_type="contacts", e.g. {"labels__name": "vip"} |
csv_file | FileField | Uploaded CSV when audience_type="csv" |
parameter_mappings | JSONField | Maps template variable index to a field name, e.g. {"1": "name", "2": "order_id"} |
status | CharField | draft, scheduled, running, completed, failed, or paused |
scheduled_at | DateTimeField | Optional future datetime for a scheduled send |
started_at | DateTimeField | Timestamp when the campaign began executing |
completed_at | DateTimeField | Timestamp when the campaign finished executing |
total_count | PositiveIntegerField | Total audience size resolved at run time |
sent_count | PositiveIntegerField | Messages accepted by Meta |
delivered_count | PositiveIntegerField | Delivery confirmations received via webhook |
read_count | PositiveIntegerField | Read receipts received via webhook |
failed_count | PositiveIntegerField | Messages rejected by Meta or that errored |
Creating a campaign
- Go to
/whatsapp/campaigns/add/ - Select a template — only
APPROVEDtemplates appear (or all templates if none are approved yet) - Choose an audience type —
contacts,csv, or a named audience key fromWHATSAPP["AUDIENCES"] - Set parameter mappings — if your template contains
{{1}},{{2}}variables, map each index to a field on the audience object (e.g.{"1": "name"}) - Optionally schedule — leave
scheduled_atblank to send immediately - Save the campaign, then click Run to execute
Audience types
contacts — WhatsAppContact records
Queries all WhatsAppContact objects with opted_out=False and is_blocked=False. Apply additional ORM filters via audience_filters:
normalized_phone and display_name for the send.
csv — Uploaded file
Upload a CSV with at minimum a phone column. Any additional columns (e.g. name, order_id) are available for parameter_mappings.
91 (India).
Named audiences — custom querysets
Register a callable insettings.py that returns a queryset or list:
PHONE_FIELD (default "phone") and NAME_FIELD (default "name") settings control which attributes are read from each object.
Running a campaign programmatically
run_campaign_async automatically falls back to synchronous execution if Celery is not configured, so it is safe to call in all environments.
Campaign analytics
Each campaign’s detail page at/whatsapp/campaigns/<pk>/ shows a live breakdown of:
- Total — audience size at the time the campaign was run
- Sent — accepted by Meta
- Delivered — delivery confirmed by Meta webhook
- Read — opened by the recipient
- Failed — rejected by Meta or errored during send
/whatsapp/analytics/ aggregates sent_count, delivered_count, read_count, and failed_count across all completed campaigns.
WhatsAppCampaignRecipient model
Every contact in the audience gets aWhatsAppCampaignRecipient row that tracks the per-recipient outcome:
| Field | Description |
|---|---|
phone_number | Recipient phone number |
name | Resolved display name |
parameters | The template variable values used for this recipient |
status | pending, sent, delivered, read, or failed |
message_id | Meta message ID (wamid.*) returned on a successful send |
error_message | Error detail from Meta if the send failed |
sent_at | Timestamp of the successful API call |
sent_at descending.