Skip to content

WhatsAppTool

fastagency.runtimes.autogen.tools.WhatsAppTool #

WhatsAppTool(
    whatsapp_api_key: str,
    whatsapp_openapi_url: str = WHATSAPP_OPENAPI_URL,
    whatsapp_api_server: str = WHATSAPP_API_SERVER,
)

Bases: Toolable

Create a new WhatsAppTool instance.

PARAMETER DESCRIPTION
whatsapp_api_key

The WhatsApp API key.

TYPE: str

whatsapp_openapi_url

Url of the openapi schema for Infobip WhatsApp API, defaults to https://dev.infobip.com/openapi/products/whatsapp.json

TYPE: str DEFAULT: WHATSAPP_OPENAPI_URL

whatsapp_api_server

Url of the Infobip WhatsApp API server, defaults to https://api.infobip.com

TYPE: str DEFAULT: WHATSAPP_API_SERVER

Source code in fastagency/runtimes/autogen/tools/whatsapp.py
def __init__(
    self,
    whatsapp_api_key: str,
    whatsapp_openapi_url: str = WHATSAPP_OPENAPI_URL,
    whatsapp_api_server: str = WHATSAPP_API_SERVER,
):
    """Create a new WhatsAppTool instance.

    Args:
        whatsapp_api_key (str): The WhatsApp API key.
        whatsapp_openapi_url (str): Url of the openapi schema for Infobip WhatsApp API, defaults to https://dev.infobip.com/openapi/products/whatsapp.json
        whatsapp_api_server (str): Url of the Infobip WhatsApp API server, defaults to https://api.infobip.com
    """
    self.whatsapp_api = OpenAPI.create(
        openapi_url=whatsapp_openapi_url,
        servers=[{"url": whatsapp_api_server}],
    )

    header_authorization = f"App {whatsapp_api_key}"
    self.whatsapp_api.set_security_params(
        APIKeyHeader.Parameters(value=header_authorization)
    )

whatsapp_api instance-attribute #

whatsapp_api = create(
    openapi_url=whatsapp_openapi_url,
    servers=[{"url": whatsapp_api_server}],
)

register #

register(
    *,
    caller: ConversableAgent,
    executor: Union[
        ConversableAgent, list[ConversableAgent]
    ]
) -> None
Source code in fastagency/runtimes/autogen/tools/whatsapp.py
def register(
    self,
    *,
    caller: ConversableAgent,
    executor: Union[ConversableAgent, list[ConversableAgent]],
) -> None:
    executors = executor if isinstance(executor, list) else [executor]

    self.whatsapp_api._register_for_llm(caller, functions=WHATSAPP_FUNCTIONS)

    for executor in executors:
        self.whatsapp_api._register_for_execution(
            executor, functions=WHATSAPP_FUNCTIONS
        )