whatsapp broadcast
This commit is contained in:
parent
63011f7d96
commit
70ccb720aa
9 changed files with 570 additions and 4 deletions
|
|
@ -123,6 +123,33 @@ class WhatsAppGraphClient:
|
|||
}
|
||||
)
|
||||
|
||||
async def send_marketing_template(
|
||||
self,
|
||||
to: str,
|
||||
name: str,
|
||||
language_code: str = "en",
|
||||
components: list[dict[str, Any]] | None = None,
|
||||
product_policy: str = "STRICT",
|
||||
) -> dict[str, Any]:
|
||||
"""Send a marketing template through Meta's marketing endpoint, not /messages."""
|
||||
if not self.configured:
|
||||
raise WhatsAppGraphError("WhatsApp Graph API is not configured", status_code=503)
|
||||
template: dict[str, Any] = {"name": name, "language": {"code": language_code}}
|
||||
if components:
|
||||
template["components"] = components
|
||||
return await self._request(
|
||||
"POST",
|
||||
self._graph_url(f"{self.phone_number_id}/marketing_messages"),
|
||||
json_payload={
|
||||
"messaging_product": "whatsapp",
|
||||
"recipient_type": "individual",
|
||||
"to": to,
|
||||
"type": "template",
|
||||
"template": template,
|
||||
"product_policy": product_policy,
|
||||
},
|
||||
)
|
||||
|
||||
async def send_interactive_buttons(
|
||||
self,
|
||||
to: str,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue