create_template
Create customizable WhatsApp Business message templates with dynamic variables for order confirmations, appointment reminders, and promotional communications.
Instructions
Create a new message template
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| category | No | Template category | |
| description | No | Template description | |
| name | Yes | Template name | |
| tags | No | Template tags | |
| text | Yes | Template text with {{variables}} | |
| variables | No | List of variable names |
Implementation Reference
- src/index.ts:745-764 (handler)Primary handler function for the 'create_template' MCP tool. It constructs the template object from input arguments and delegates to TemplateService.createTemplate, then formats and returns the result.private async handleCreateTemplate(args: any) { const template = await templateService.createTemplate({ name: args.name, description: args.description, category: args.category, content: { text: args.text }, variables: args.variables, tags: args.tags }); return { content: [ { type: 'text', text: JSON.stringify(template, null, 2) } ] }; }
- src/index.ts:223-245 (registration)Registration of the 'create_template' tool in the tools array, including name, description, and input schema definition.{ name: 'create_template', description: 'Create a new message template', inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Template name' }, description: { type: 'string', description: 'Template description' }, category: { type: 'string', description: 'Template category' }, text: { type: 'string', description: 'Template text with {{variables}}' }, variables: { type: 'array', items: { type: 'string' }, description: 'List of variable names' }, tags: { type: 'array', items: { type: 'string' }, description: 'Template tags' } }, required: ['name', 'text'] }
- Core helper method in TemplateService that generates ID, creates the MessageTemplate object, stores it in memory map, persists to file, and returns the new template.async createTemplate(template: Omit<MessageTemplate, 'id' | 'createdAt' | 'updatedAt'>): Promise<MessageTemplate> { const id = this.generateTemplateId(template.name); const newTemplate: MessageTemplate = { ...template, id, createdAt: new Date(), updatedAt: new Date() }; this.templates.set(id, newTemplate); await this.saveCustomTemplates(); return newTemplate; }
- src/index.ts:512-513 (handler)Dispatch case in the main CallToolRequestSchema handler that routes 'create_template' calls to the specific handleCreateTemplate method.case 'create_template': return await this.handleCreateTemplate(args);
- src/index.ts:226-244 (schema)JSON schema defining input validation for the 'create_template' tool parameters.inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Template name' }, description: { type: 'string', description: 'Template description' }, category: { type: 'string', description: 'Template category' }, text: { type: 'string', description: 'Template text with {{variables}}' }, variables: { type: 'array', items: { type: 'string' }, description: 'List of variable names' }, tags: { type: 'array', items: { type: 'string' }, description: 'Template tags' } }, required: ['name', 'text']