Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions bindu/integrations/whatsapp/WhatsAppCloudBot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import requests
import os

class WhatsAppCloudBot:
"""
WhatsApp Cloud API Integration for Bindu Agents.
Enables agents to interact with users directly via WhatsApp.
"""
def __init__(self):
self.api_url = "https://graph.facebook.com/v17.0"
self.access_token = os.getenv("WHATSAPP_TOKEN")
self.phone_number_id = os.getenv("WHATSAPP_PHONE_ID")

def send_message(self, to, text):
url = f"{self.api_url}/{self.phone_number_id}/messages"
headers = {"Authorization": f"Bearer {self.access_token}"}
payload = {
"messaging_product": "whatsapp",
"to": to,
"type": "text",
"text": {"body": text}
}
return requests.post(url, headers=headers, json=payload)