- Home
- Skills
- APIs & Backend
- WhatsApp Business Notify — Python Cloud API Integration
Works with the AI Agents you already use
WhatsApp Business Notify — Python Cloud API Integration
Secure Python integration for WhatsApp Cloud API with webhook validation and session window management.
$34.99
WhatsApp Business Notify — Python Cloud API Integration
Example session with this skill installed
I need a Python implementation for the WhatsApp Cloud API. I need to send templates, handle webhooks securely, and track the 24-hour session window.
- Read your context and instructions
- Compiled the whatsapp business notify
I have generated a secure Python integration for the WhatsApp Business Cloud API. This includes the API client, webhook validator, and session management logic.
WhatsApp Business Integration
import hmac
import hashlib
import time
from datetime import datetime, timezone, timedelta
import requests
class WhatsAppClient:
def __init__(self, token, phone_number_id, version="v18.0"):
self.base_url = f"https://graph.facebook.com/{version}/{phone_number_id}"
self.headers = {"Authorization": f"Bearer {token}", "Content-Type": "application/json"}
def send_template(self, to, template_name, lang_code="en_US", components=None):
payload = {
"messaging_product": "whatsapp",
"to": to,
"type": "template",
"template": {
"name": template_name,
"language": {"code": lang_code},
"components": components or []
}
}
return requests.post(f"{self.base_url}/messages", json=payload, headers=self.headers)
class WebhookValidator:
@staticmethod
def verify_signature(payload, signature, app_secret):
expected = hmac.new(
app_secret.encode('utf-8'),
payload,
hashlib.sha256
).hexdigest()
return hmac.compare_digest(f"sha256={expected}", signature)
class SessionManager:
@staticmethod
def is_window_open(last_inbound_timestamp):
if not last_inbound_timestamp:
return False
now = datetime.now(timezone.utc)
return now < last_inbound_timestamp + timedelta(hours=24)
Next steps
- Add
WHATSAPP_ACCESS_TOKENandWHATSAPP_APP_SECRETto your.envfile. - Deploy the
WebhookValidatorlogic to your endpoint to handle the Meta verification challenge. - Register your message templates in the Meta Business Suite before attempting to send them via the client.
Connects securely to your tools. The creator never sees your data.
About this skill
Building a production-ready WhatsApp integration requires more than just calling an endpoint. You have to manage 24-hour session windows, validate webhook signatures, handle asynchronous delivery statuses, and ensure opt-out compliance. This skill provides a structured Python implementation for the official WhatsApp Business Platform Cloud API. It eliminates the guesswork in managing message states and security protocols.
What it does
- API Client Implementation handles authenticated calls, timeout management, and error normalization for the Cloud API.
- Session Management tracks inbound message timestamps to enforce the 24-hour customer service window.
- Webhook Security validates incoming Meta signatures and handles verification challenges to prevent spoofing.
- Template Handling manages approved templates, categories, and language codes for outbound notifications.
- Reliability Logic implements bounded exponential backoff for transient failures and idempotent event processing.
How it works
- Initialize Client using environment variables for phone number IDs and access tokens.
- Configure Webhooks by deploying the validation endpoint and setting up signature checking.
- Execute Messages by calling the service layer with text, media, or template-based payloads.
- Monitor Events to update message statuses from 'accepted' to 'delivered' or 'read' via webhooks.
Frameworks & tools
Python, WhatsApp Business Cloud API (Meta), and environment-based secret management. The implementation is designed to integrate with FastAPI, Flask, or Django.
Why this beats prompting it yourself
Generic prompts often ignore the complexity of the 24-hour session window and fail to implement mandatory webhook signature validation. This skill follows the official Meta implementation patterns, ensuring your account stays compliant and your webhooks stay secure.
Use cases
- Sending automated order confirmations using approved business templates.
- Building a customer support bot that respects the 24-hour service window.
- Syncing message delivery and read receipts back to a local database.
- Managing user opt-outs and subscription preferences at the API level.
Known limitations
Requires an active Meta Developer App and a verified WhatsApp Business Account. Does not support unofficial WhatsApp Web scraping or automation.
Requires active Meta Developer App and WhatsApp Business Account. Does not support unofficial Web automation. Users must provide their own persistence layer for message IDs.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before any payment.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 24 days ago