# Send notifications with WhatsApp Business Cloud

The WhatsApp Business Cloud integration sends your booking and training notifications from your own WhatsApp Business number through Meta's official Cloud API, and brings customer replies and delivery receipts back into PiGi. You need your own Meta business portfolio, a Meta app, a phone number that is not already on WhatsApp, a payment card for Meta's per-message charges, and message templates that Meta has approved.

Source: https://help.pigi.io/guides/integrations/communication/whatsapp-business

## Quick answers

**Should I use WhatsApp Business Cloud or the QR-code WhatsApp connection?**
Use WhatsApp Business Cloud. It is Meta's official route: your own number, your own
templates and billing, and no phone that has to stay paired. The older QR pairing
(see Connect WhatsApp) still works for schools already on it, but do not pair a new
number that way. If both are set up, PiGi sends through WhatsApp Business Cloud.

**What does WhatsApp Business Cloud cost?**
PiGi does not charge for it. Meta charges per delivered template message, at rates that
depend on the template's category and the customer's country. Replies you send while a
customer's 24-hour window is open are free, and so are Utility templates sent inside that
window. See Meta's pricing page for current rates.

**Can I use the number I already have on WhatsApp?**
Only if you delete that WhatsApp or WhatsApp Business app account first, which loses its
chat history. A number that has never been on WhatsApp is easier. A landline works if
you take Meta's code by voice call.

**Is there a click-by-click guide to the Meta setup?**
Yes: **Set up your Meta app and token for WhatsApp Business Cloud** walks through the app,
the system user and its asset access, every ID, the webhook, test commands and each error
Meta or PiGi can show.

**Where do I find the Phone number ID and WhatsApp Business Account ID?**
In your Meta app, open the WhatsApp **API Setup** page: the Phone number ID is shown under
your sending number, and the WhatsApp Business Account ID is on the same page. The
account ID is also the number after `asset_id=` in the address bar of WhatsApp Manager.
The Phone number ID is not the phone number itself.

**What callback URL do I give Meta?**
`https://api.pigi.io/api/v1/notifications/public/webhooks/whatsapp/`, with the same
**Webhook verify token** you saved in PiGi. Subscribe to the `messages` field.

**Which templates do I need?**
One approved template per notification you want to send by WhatsApp. The standard pack:

| Template name | Category | Sent when |
|---|---|---|
| booking_confirmed | Utility | A booking is made |
| check_in_reminder | Utility | Check-in reminder |
| launch_site_changed | Utility | The launch site changes |
| flights_on_hold | Utility | Flights are put on hold |
| flying_day_cancelled | Utility | A flying day is cancelled |
| flying_resumed | Utility | Flying resumes |
| document_verification_needed | Utility | A compliance form needs checking (to staff) |
| flight_signoff_requested | Utility | A student asks for flight sign-off (to instructors) |
| conversation_follow_up | Utility | Restarting a chat after 24 hours |
| photo_video_addon | Marketing | Optional: offering the photo and video package |

The full wording, variable samples, footer and button for all ten templates are ready to
copy into WhatsApp Manager in **WhatsApp message templates to submit to Meta**.

**Why was my template rejected?**
The usual reasons: the body starts or ends with a variable, two variables sit side by side
or a variable sits alone on a line, there are too many variables for the length, or a
Utility template contains selling wording. Put a label before every variable
("Date: {{start_date}}"), end the body with fixed text, use named variables in lowercase
with underscores, and keep offers and add-ons out of Utility templates.

**Why can I only message 250 people a day?**
Meta limits a new business to 250 different people a day outside open 24-hour windows.
Verify your business in Meta Business Settings → Security Center to raise it. You can keep
sending while verification is under review.

**Meta wants to send my verification code to a number I don't recognise. What do I do?**
Meta matches you to a public company record and offers to call, text or WhatsApp the
number on that record, which may be out of date. Don't use it. Choose **Identity
verification** instead (a listed director, from their own account, with their ID), or
**My business isn't listed** and upload your company registration with a recent utility
bill or bank statement.

**Why does a WhatsApp chat only offer "Send follow-up"?**
The customer last wrote more than 24 hours ago, and WhatsApp only lets you send an
approved template until they reply. PiGi shows "More than 24 hours since they last
wrote." in the chat, in the WhatsApp chats page and in a booking's chat. Press **Send
follow-up** to send your `conversation_follow_up` template; once the customer replies you
can chat freely for another 24 hours. While the window is open, a booking's chat shows
when free replies stop.

**Why do some messages arrive by SMS instead of WhatsApp?**
Payment receipts, offline registration links, website chat verification codes and the
chatbot's hand-off alert are messages your school starts, so on WhatsApp Business Cloud
they can only go as free text inside the customer's 24-hour window. Outside it, PiGi
sends the same message by SMS, if you have an SMS method set up. Opted-out numbers are
not texted instead.

**What happens if a customer is not on WhatsApp?**
If you have an SMS method set up, PiGi sends the message by SMS instead, using that
event's SMS wording if you have one, otherwise the WhatsApp text in plain characters. A
number that turns out not to be on WhatsApp goes straight to SMS for the next 90 days.
SMS follows the **Countries to text** setting on your SMS integration.

**Can I post to WhatsApp groups with the Cloud API?**
No. Meta's Cloud API sends to phone numbers only.

## What this does

WhatsApp Business Cloud connects PiGi to your own WhatsApp Business number through Meta.
PiGi sends each WhatsApp notification as the Meta-approved template you choose for it,
filled with the booking's details. Customer replies, delivery and read receipts, and
opt-out keywords come back into PiGi.

Meta only lets a business start a conversation with an approved template. Free text
reaches someone only within 24 hours of their last message to you. Meta charges per
delivered template; see Meta's pricing page.

## Before you start

- A personal Facebook account with two-factor authentication on, and an email you can read.
- A Meta business portfolio at business.facebook.com with your registered company details.
- A phone number that is not on WhatsApp, and a payment card for Meta's charges.
- Your website address and privacy policy URL.
- The **admin** role in PiGi.

## Set up WhatsApp Business Cloud with Meta

1. At developers.facebook.com, register as a Meta developer, then **My Apps → Create app**
   with the use case **Connect with customers through WhatsApp**, linked to your business
   portfolio. Keep "WhatsApp", "Meta" and "Facebook" out of the app name.
2. In the app, open **Use cases → WhatsApp → Customize → Production setup** (older
   screens: **WhatsApp → API Setup → Add phone number**). Create the WhatsApp Business
   Account, set a display name that matches your business, add your number and confirm
   it with Meta's code.
3. In WhatsApp Manager → **Phone numbers**, check the number shows **Connected**. If it
   asks to be registered, set a 6-digit two-step verification PIN.
4. Add a payment method to the WhatsApp Business Account. Without one, messages are
   accepted but never delivered.
5. In **Business settings → Users → System users**, create a system user, assign it full
   control of the app, the **Messaging account** and the number, then **Generate token**:
   pick your app, expiry **Never**, and tick `whatsapp_business_messaging` and
   `whatsapp_business_management`.
   Copy the token: Meta shows it once.
6. Copy the **App secret** from **App settings → Basic**.
7. In **Business settings → Security Center**, verify your business to lift the
   250-a-day limit. Don't accept a code sent to a number you don't recognise (see Quick
   answers).

## Connect WhatsApp Business Cloud to PiGi

1. Open **Company → Settings → Integrations** and click **WhatsApp Business Cloud**.
2. Press **Connect WhatsApp Business Cloud**, then **Add credentials**.
3. Fill in **Access token**, **Phone number ID**, **WhatsApp Business Account ID**,
   **App secret** and **Webhook verify token** (any long random text you make up), then
   **Save**.
4. Press **Test connection**. PiGi checks the number and subscribes your app to your
   WhatsApp account's events.
5. In the Meta app, open **WhatsApp → Configuration** (or **Use cases → WhatsApp →
   Customize → Configuration**). Paste the callback URL
   `https://api.pigi.io/api/v1/notifications/public/webhooks/whatsapp/` and the same
   verify token, press **Verify and save**, then subscribe to `messages`.
6. Under **Company → Settings → Notifications → Methods**, choose **WhatsApp Business
   Cloud** for WhatsApp.
7. Publish the Meta app (privacy policy URL, app domain, category, then **Live**).
8. In WhatsApp Manager → **Message templates**, submit your templates, using the wording
   in **WhatsApp message templates to submit to Meta**. Once approved, open
   each WhatsApp notification template in PiGi and pick it under **Approved Meta
   template**. If PiGi warns that its message differs from the approved text, press
   **Use the approved text**. If the template has a link button, choose the link under
   the button's "opens" list.

## Test WhatsApp Business Cloud

1. **Test connection** should show **Connection works** with "Connected as … Webhook
   subscribed."
2. Message your new number from your own phone, then open a WhatsApp notification in
   PiGi and press **Send test**. The result names the template it sent.
3. Reply to the message and check the reply appears in PiGi's WhatsApp chats.

## Troubleshooting

- **"Enter the access token and phone number ID first."** Add both under **Update credentials**.
- **"Meta refused the token or number: …"** The token is wrong, expired or missing
  permissions, or the Phone number ID is wrong. Generate a permanent system-user token.
- **"… is not registered for the Cloud API yet"** Register the number in WhatsApp Manager
  with a 6-digit PIN.
- **"…but the WhatsApp Business Account ID is missing."** or **"…the webhook subscription
  failed"** Give the system user full control of the **Messaging account**, generate a
  new token, and check the ID has no trailing full stop.
- **"outside WhatsApp's 24-hour window: this message needs an approved template"** Pick
  an approved template on that notification.
- **"no value for {{…}}"** That detail was empty for the booking, or PiGi's message uses
  a variable the event does not provide.
- **"No templates on your WhatsApp Business Account yet."** Create them in WhatsApp Manager.
- **Meta shows "An error occurred (#1004)" on Verify and save.** Reload the page; the URL
  has often saved.

## Known limitations

- PiGi cannot check in advance whether a number is on WhatsApp; it learns from each send.
- Template review can take up to 24 hours and Meta offers no way to speed it up.
- An operations update you type is sent as one paragraph; line breaks become spaces.
- Group posts are not available on the Cloud API.

## Sources

- [Meta: Get started with the Cloud API](https://developers.facebook.com/docs/whatsapp/cloud-api/get-started)
- [Meta: Messaging limits](https://developers.facebook.com/docs/whatsapp/messaging-limits)
- [Meta: Message templates](https://developers.facebook.com/docs/whatsapp/business-management-api/message-templates)
- [Meta: Template review](https://developers.facebook.com/documentation/business-messaging/whatsapp/templates/template-review)
- [Meta: Pricing](https://developers.facebook.com/docs/whatsapp/pricing)
- [Meta: Set up webhooks](https://developers.facebook.com/docs/whatsapp/cloud-api/guides/set-up-webhooks)
