Skip to main content
Glama

send_message

Send WhatsApp messages directly to phone numbers or existing chats. Use this tool to communicate with contacts through automated browser interaction.

Instructions

Send a WhatsApp message using either a phone number or an existing chat name.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
phone_numberNoRecipient phone number in international or local format.
chat_nameNoVisible WhatsApp chat name to open from the sidebar search.
textYesMessage body to send.

Implementation Reference

  • The actual implementation of the send_message tool logic.
    async def send_message(
        self,
        text: str,
        phone_number: str | None = None,
        chat_name: str | None = None,
    ) -> dict[str, Any]:
        await self._require_ready()
        assert self._page is not None
    
        target = await self._open_target_chat(phone_number=phone_number, chat_name=chat_name, prefill_text=text)
        await self._wait_for_message_box()
        if target["type"] == "chat_name":
            await self._fill_message_box(text)
        await self._click_first_visible(SEND_BUTTON_SELECTORS)
    
        return {
            "status": "sent",
            "target": target,
            "message": text,
        }
  • Registration and definition of the send_message tool in the MCP server.
    "send_message": ToolDefinition(
        name="send_message",
        description="Send a WhatsApp message using either a phone number or an existing chat name.",
        input_schema={
            "type": "object",
            "properties": {
                "phone_number": {"type": "string", "description": "Recipient phone number in international or local format."},
                "chat_name": {"type": "string", "description": "Visible WhatsApp chat name to open from the sidebar search."},
                "text": {"type": "string", "description": "Message body to send."},
            },
            "required": ["text"],
            "additionalProperties": False,
        },
        handler=lambda args: self.client.send_message(
            text=args["text"],
            phone_number=args.get("phone_number"),
            chat_name=args.get("chat_name"),
        ),
    ),

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ekaksher/whatsapp-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server