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);

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/luiso2/mcp-evolution-api'

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