WhatsAppToolkit

class WhatsAppToolkit(BaseToolkit):

A class representing a toolkit for WhatsApp operations.

This toolkit provides methods to interact with the WhatsApp Business API, allowing users to send messages, retrieve message templates, and get business profile information.

Attributes: retries (int): Number of retries for API requests in case of failure. delay (int): Delay between retries in seconds. base_url (str): Base URL for the WhatsApp Business API. version (str): API version.

init

def __init__(self, timeout: Optional[float] = None):

Initializes the WhatsAppToolkit.

send_message

def send_message(self, to: str, message: str):

Sends a text message to a specified WhatsApp number.

Parameters:

  • to (str): The recipient’s WhatsApp number in international format.
  • message (str): The text message to send.

Returns:

Union[Dict[str, Any], str]: A dictionary containing the API response if successful, or an error message string if failed.

get_message_templates

def get_message_templates(self):

Returns:

Union[List[Dict[str, Any]], str]: A list of dictionaries containing template information if successful, or an error message string if failed.

get_business_profile

def get_business_profile(self):

Returns:

Union[Dict[str, Any], str]: A dictionary containing the business profile information if successful, or an error message string if failed.

get_tools

def get_tools(self):

Returns:

List[FunctionTool]: A list of FunctionTool objects for the toolkit methods.