Skip to main content
Glama
Jem-HR
by Jem-HR

send_template

Send pre-approved WhatsApp template messages with customizable parameters for consistent business communication.

Instructions

Send a WhatsApp template message.

Args: to: Phone number or WhatsApp ID name: Template name/ID language: Template language code (default: en) params: Optional template parameters (header, body, button components) reply_to_message_id: Message ID to reply to

Returns: Dictionary with success status and message ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
toYes
nameYes
languageNoen
paramsNo
reply_to_message_idNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for send_template tool. This async function sends WhatsApp template messages with parameters for recipient phone number, template name, language code, optional template parameters, and reply-to message ID. It calls the underlying pywa library's send_template method and returns a success/failure response with message details.
    async def send_template(
        to: str,
        name: str,
        language: str = "en",
        params: Optional[List[Dict[str, Any]]] = None,
        *,
        reply_to_message_id: Optional[str] = None,
    ) -> dict:
        """
        Send a WhatsApp template message.
        
        Args:
            to: Phone number or WhatsApp ID
            name: Template name/ID
            language: Template language code (default: en)
            params: Optional template parameters (header, body, button components)
            reply_to_message_id: Message ID to reply to
        
        Returns:
            Dictionary with success status and message ID
        """
        try:
            result = wa_client.send_template(
                to=to,
                name=name,
                language=language,
                params=params or [],
                reply_to_message_id=reply_to_message_id,
            )
            
            logger.info(f"Template '{name}' sent to {to}")
            message_id = getattr(result, 'id', str(result)) if result else None
            return {
                "success": True,
                "message_id": message_id,
                "template": name,
                "to": to,
            }
        except Exception as e:
            logger.error(f"Failed to send template: {str(e)}")
            return {"success": False, "error": str(e)}
  • The registration function that creates and registers the send_template tool with the MCP server. This function defines the tool's schema via function signature and decorators, making it available for use by the MCP client.
    def register_template_tools(mcp, wa_client: WhatsApp):
        """Register template-related tools."""
        
        @mcp.tool()
        async def send_template(
            to: str,
            name: str,
            language: str = "en",
            params: Optional[List[Dict[str, Any]]] = None,
            *,
            reply_to_message_id: Optional[str] = None,
        ) -> dict:
            """
            Send a WhatsApp template message.
            
            Args:
                to: Phone number or WhatsApp ID
                name: Template name/ID
                language: Template language code (default: en)
                params: Optional template parameters (header, body, button components)
                reply_to_message_id: Message ID to reply to
            
            Returns:
                Dictionary with success status and message ID
            """
            try:
                result = wa_client.send_template(
                    to=to,
                    name=name,
                    language=language,
                    params=params or [],
                    reply_to_message_id=reply_to_message_id,
                )
                
                logger.info(f"Template '{name}' sent to {to}")
                message_id = getattr(result, 'id', str(result)) if result else None
                return {
                    "success": True,
                    "message_id": message_id,
                    "template": name,
                    "to": to,
                }
            except Exception as e:
                logger.error(f"Failed to send template: {str(e)}")
                return {"success": False, "error": str(e)}
  • The schema/type definition for the send_template tool. Defined through Python type hints in the function signature, specifying that it takes a required string 'to' and 'name', an optional string 'language' with default 'en', optional list of dicts for 'params', and optional 'reply_to_message_id'. Returns a dictionary.
        to: str,
        name: str,
        language: str = "en",
        params: Optional[List[Dict[str, Any]]] = None,
        *,
        reply_to_message_id: Optional[str] = None,
    ) -> dict:
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It states the action ('Send') but doesn't disclose behavioral traits like required permissions, rate limits, error conditions, or what happens if the template doesn't exist. The return format is mentioned but lacks detail on failure cases.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded with the core purpose. The parameter explanations are organized but slightly verbose; every sentence earns its place by clarifying parameters that lack schema descriptions.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given 5 parameters with 0% schema coverage and no annotations, the description does well on parameters but lacks behavioral context for a mutation tool. The output schema exists, so return values don't need explanation, but completeness is moderate due to missing operational details.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description compensates by explaining all 5 parameters: 'to' (phone/ID), 'name' (template name/ID), 'language' (code with default), 'params' (optional components), and 'reply_to_message_id' (message ID). This adds significant meaning beyond the bare schema, though some details like param structure could be clearer.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Send a WhatsApp template message') with the resource identified. It distinguishes this tool from siblings like 'send_message' or 'send_message_with_buttons' by specifying it's for template-based messages, not free-form or button-based ones.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for sending WhatsApp template messages, but doesn't explicitly state when to use this versus alternatives like 'send_message' or 'send_message_with_buttons'. No guidance on prerequisites or exclusions is provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/Jem-HR/pywa-mcp-server'

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