Skip to main content
Glama
luiso2

Evolution API WhatsApp MCP Server

by luiso2

send_template

Send pre-approved WhatsApp Business template messages with dynamic variables for order confirmations, appointment reminders, and promotional communications.

Instructions

Send a message using a template

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
instanceNameYesInstance name
numberYesRecipient phone number
templateIdYesTemplate ID
variablesYesVariables to replace in template

Implementation Reference

  • The handler function that implements the core logic for the 'send_template' tool. Retrieves the template, validates and processes variables, then sends the message via appropriate API calls.
    private async handleSendTemplate(args: any) {
      const template = templateService.getTemplate(args.templateId);
      if (!template) {
        throw new Error(`Template ${args.templateId} not found`);
      }
    
      // Validate variables
      const missingVars = templateService.validateVariables(template, args.variables);
      if (missingVars.length > 0) {
        throw new Error(`Missing variables: ${missingVars.join(', ')}`);
      }
    
      // Process template
      const processedContent = templateService.processTemplate(template, args.variables);
    
      // Send message based on content type
      let result;
      if (processedContent.text) {
        result = await evolutionAPI.sendText(args.instanceName, {
          number: args.number,
          text: processedContent.text
        });
      } else if (processedContent.listMessage) {
        result = await evolutionAPI.sendList(args.instanceName, {
          number: args.number,
          ...processedContent.listMessage
        });
      } else if (processedContent.buttons) {
        result = await evolutionAPI.sendButtons(args.instanceName, {
          number: args.number,
          buttons: processedContent.buttons
        });
      }
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result, null, 2)
          }
        ]
      };
    }
  • The tool definition including name, description, and input schema for 'send_template', used for tool listing and validation.
    {
      name: 'send_template',
      description: 'Send a message using a template',
      inputSchema: {
        type: 'object',
        properties: {
          instanceName: { type: 'string', description: 'Instance name' },
          number: { type: 'string', description: 'Recipient phone number' },
          templateId: { type: 'string', description: 'Template ID' },
          variables: {
            type: 'object',
            description: 'Variables to replace in template'
          }
        },
        required: ['instanceName', 'number', 'templateId', 'variables']
      }
    },
  • src/index.ts:514-515 (registration)
    The dispatch case in the CallToolRequest handler that routes 'send_template' calls to the specific handler method.
    case 'send_template':
      return await this.handleSendTemplate(args);

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

C2.8/5.0
Behavior2/5

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

No annotations provided, and the description does not disclose behavioral traits such as whether templates must be approved, how variables are substituted, or any side effects. Minimal transparency.

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

Conciseness3/5

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

Very concise at 6 words, but lacks necessary detail to be fully useful. Front-loads the core action, but misses context for agent decision-making.

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

Completeness2/5

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

Given no output schema, no annotations, and multiple sibling tools, the description is incomplete. It does not explain template usage, variable format, or when to prefer this over other send tools.

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

Parameters3/5

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

Schema covers all parameters with descriptions, so baseline is 3. The description adds no extra meaning beyond 'send using template', which is already implied by the tool name and schema.

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

Purpose4/5

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

The description clearly states the verb 'send' and resource 'message using a template', distinguishing it from siblings like send_text and send_media. However, it does not elaborate on what a template is or imply the pre-approved nature.

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

Usage Guidelines2/5

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

No guidance on when to use this tool versus alternatives like send_text, send_list, or send_buttons. The description lacks any context about appropriate use cases or prerequisites.

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