list_templates
Retrieve available WhatsApp message templates for business messaging, with options to filter by category or tags to find suitable templates for order confirmations, appointment reminders, or promotional messages.
Instructions
List all message templates
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| category | No | Filter by category | |
| tags | No | Filter by tags |
Implementation Reference
- src/index.ts:709-728 (handler)Main handler function for the 'list_templates' tool. It checks input arguments for category or tags filters and calls the appropriate TemplateService method to retrieve templates, then returns them as JSON text content.private async handleListTemplates(args: any) { let templates; if (args.category) { templates = templateService.getTemplatesByCategory(args.category); } else if (args.tags && args.tags.length > 0) { templates = templateService.getTemplatesByTags(args.tags); } else { templates = templateService.getAllTemplates(); } return { content: [ { type: 'text', text: JSON.stringify(templates, null, 2) } ] }; }
- src/index.ts:200-210 (schema)Input schema for the list_templates tool, defining optional category (string) and tags (array of strings) parameters for filtering templates.inputSchema: { type: 'object', properties: { category: { type: 'string', description: 'Filter by category' }, tags: { type: 'array', items: { type: 'string' }, description: 'Filter by tags' } } }
- src/index.ts:197-211 (registration)Tool definition object registered in the 'tools' array, which is returned by the ListTools handler.{ name: 'list_templates', description: 'List all message templates', inputSchema: { type: 'object', properties: { category: { type: 'string', description: 'Filter by category' }, tags: { type: 'array', items: { type: 'string' }, description: 'Filter by tags' } } } },
- src/index.ts:508-509 (registration)Switch case in the CallToolRequest handler that dispatches 'list_templates' calls to the specific handleListTemplates method.case 'list_templates': return await this.handleListTemplates(args);
- Core helper method in TemplateService that retrieves all templates from the internal map, used by the handler when no filters are specified.getAllTemplates(): MessageTemplate[] { return Array.from(this.templates.values()); }