Skip to main content

WhatsAppToolkit

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. Parameters:
  • 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

Initializes the WhatsAppToolkit.

send_message

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

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

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

get_tools

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