httpx dependency the interface needs ships with Agno, so no extra install is required.
1
Prerequisites
- A Meta Developer Account
- A Meta Business Portfolio (Business Account)
- ngrok or cloudflared (to expose your local server)
- Python 3.9+
2
Create a Meta Business Account
- Go to Meta Business Manager and create a Business Portfolio.
- Complete business verification to unlock production messaging limits and API access.
3
Create a Meta App
- Open the Apps Dashboard and click Create app.
- Under App details, give it a name and continue.
- Under Use cases, select Connect with customers through WhatsApp, then click Next.
- Under Business, link the app to the Business Portfolio from the previous step, then finish the Requirements and Overview steps to create the app.
- On the app dashboard, click Customize the Connect with customers through WhatsApp use case (or open Use cases in the sidebar) to set up WhatsApp. This creates your WhatsApp Business Account (WABA).
4
Get Your Token and Phone Number ID
In the Connect with customers through WhatsApp use case, go to Basic setup > Step 1. Try it out. Copy each value and set it as an environment variable:
- Meta claims a WhatsApp test number under Test number. Copy the Phone Number ID shown next to it:
- Under Access token, click Generate token and copy it. This temporary token expires after ~24 hours and is for development only:
The test number can message any recipient you register on the Step 1. Try it out page. Adding and verifying your own business number with a permanent token is only required for production. See Add a Phone Number.
5
Get Your App Secret
- In the side menu, open App settings > Basic.
- Copy the App Secret. It is used for webhook signature verification:
6
Set the Remaining Environment Variables
7
Start the Server and Tunnel It
Webhook verification requires your AgentOS server to be running and publicly reachable. Start it before configuring the webhook in Meta.
- With the env vars set, run any WhatsApp example:
- Expose it publicly with ngrok or any tunnel of your choice:
{your-public-domain}/whatsapp/webhook.8
Configure the Webhook
- In the use case, go to Basic setup > Step 2. Production setup > Configure Webhooks.
- Set Callback URL to your public domain plus
/whatsapp/webhook: - Set Verify Token to the same string as your
WHATSAPP_VERIFY_TOKEN. - Click Verify and save. Meta sends a GET challenge to your running server, which Agno verifies automatically.
9
Subscribe to Webhook Fields
After verification, Meta usually opens the Webhook fields list and auto-subscribes the standard fields. Confirm the messages field shows Subscribed, or your server never receives incoming messages even though verification succeeded.To subscribe manually:
- Open Use cases > Connect with customers through WhatsApp > Customize.
- Go to Basic setup > Step 2. Production setup and scroll to Webhook fields.
- Toggle the fields to Subscribed. messages is required; message_template_status_update and history are commonly enabled too.
10
Test It (and Register the Number if Needed)
Send a message to the test number from a recipient on your Step 1. Try it out allow-list. If your server receives the webhook and the agent replies, setup is complete.If no webhook requests arrive at your tunnel, the test number must be programmatically activated even though the dashboard shows it as “Active”. Meta returns
200 OK with a message_id but silently drops messages during routing until the number is registered. Run both calls with your access token:- Register the number (provisions your
phone_number_idon WhatsApp servers): - Subscribe the app to your WABA (links your app to the Business Account):
Replace
<WABA_ID>with your WhatsApp Business Account ID (shown under Step 1. Try it out). This call sends no body.
Signature Validation
The webhook validates incoming requests with HMAC-SHA256 over theX-Hub-Signature-256 header. If WHATSAPP_APP_SECRET is not set, the server returns 500 to fail securely.
For development, skip validation:
Production Access
Once it works, keep developing with the temporary token and test number, or move toward production by adding your own business number and generating a permanent token. Both are done from Basic setup > Step 2. Production setup (not Step 1. Try it out, which only provides the temporary token and test number).- Add your number. Under Register your WhatsApp phone number, click Add new number and verify it. You can add up to 2 numbers before business verification, and up to 20 after. Manage numbers anytime in WhatsApp Manager.
- Generate a permanent token. Still on Step 2. Production setup, scroll to Test your registered number and use Step 1: Generate permanent token to generate the token for your WhatsApp Business Account, then copy it. Unlike the temporary token, it does not expire.
- Set the permanent token as your
WHATSAPP_ACCESS_TOKEN, and updateWHATSAPP_PHONE_NUMBER_IDto your registered number’s ID. - To send business-initiated messages (marketing, utility, authentication), complete Add payment in the same step. Replies to user-initiated messages are free for the first 1,000 conversations per month.
The older Business Settings > System Users token flow now shows “No permissions available” for the WhatsApp use case. Use Step 2. Production setup instead.