update_template
Modify an existing WhatsApp Business message template by updating its name, description, text content, or variables to maintain accurate and current messaging for business communications.
Instructions
Update an existing template
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| description | No | New description | |
| name | No | New name | |
| templateId | Yes | Template ID | |
| text | No | New text | |
| variables | No | New variables list |
Implementation Reference
- src/index.ts:822-842 (handler)Main handler function for 'update_template' tool. Processes input arguments, constructs updates object, calls template service to update, handles errors, and formats MCP response.private async handleUpdateTemplate(args: any) { const updates: any = {}; if (args.name) updates.name = args.name; if (args.description) updates.description = args.description; if (args.text) updates.content = { text: args.text }; if (args.variables) updates.variables = args.variables; const updated = await templateService.updateTemplate(args.templateId, updates); if (!updated) { throw new Error(`Template ${args.templateId} not found`); } return { content: [ { type: 'text', text: JSON.stringify(updated, null, 2) } ] }; }
- src/index.ts:278-292 (schema)Input schema/JSON Schema for validating parameters of the update_template tool.inputSchema: { type: 'object', properties: { templateId: { type: 'string', description: 'Template ID' }, name: { type: 'string', description: 'New name' }, description: { type: 'string', description: 'New description' }, text: { type: 'string', description: 'New text' }, variables: { type: 'array', items: { type: 'string' }, description: 'New variables list' } }, required: ['templateId'] }
- src/index.ts:275-293 (registration)Tool definition object in the static 'tools' array returned by ListTools handler, registering name, description, and schema.{ name: 'update_template', description: 'Update an existing template', inputSchema: { type: 'object', properties: { templateId: { type: 'string', description: 'Template ID' }, name: { type: 'string', description: 'New name' }, description: { type: 'string', description: 'New description' }, text: { type: 'string', description: 'New text' }, variables: { type: 'array', items: { type: 'string' }, description: 'New variables list' } }, required: ['templateId'] } },
- src/index.ts:518-519 (registration)Dispatch registration in the CallTool request handler switch statement, routing 'update_template' calls to the specific handler method.case 'update_template': return await this.handleUpdateTemplate(args);
- Supporting service method implementing the core template update logic: retrieves, merges updates, persists to storage, returns updated template.async updateTemplate(id: string, updates: Partial<MessageTemplate>): Promise<MessageTemplate | null> { const template = this.templates.get(id); if (!template) return null; const updatedTemplate = { ...template, ...updates, id, // Preserve ID updatedAt: new Date() }; this.templates.set(id, updatedTemplate); await this.saveCustomTemplates(); return updatedTemplate; }