search_templates
Find predefined WhatsApp message templates for business scenarios like order confirmations, appointment reminders, and promotional messages by entering search terms.
Instructions
Search templates by text
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"query": "<query>"
},
"name": "search_templates"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search query |
Implementation Reference
- src/index.ts:844-854 (handler)The handler function for the 'search_templates' tool. It calls templateService.searchTemplates with the query argument and returns the results as a JSON-formatted text response.
private async handleSearchTemplates(args: any) { const templates = templateService.searchTemplates(args.query); return { content: [ { type: 'text', text: JSON.stringify(templates, null, 2) } ] }; } - src/index.ts:297-302 (schema)Input schema definition for the 'search_templates' tool, specifying a required 'query' string parameter.
inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query' } }, required: ['query'] - src/index.ts:294-304 (registration)Registration of the 'search_templates' tool in the MCP tools array, including name, description, and input schema.
{ name: 'search_templates', description: 'Search templates by text', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query' } }, required: ['query'] } }, - The core helper method in TemplateService that performs the actual template search by filtering on name, description, tags, and category.
searchTemplates(query: string): MessageTemplate[] { const lowerQuery = query.toLowerCase(); return Array.from(this.templates.values()).filter(template => { return ( template.name.toLowerCase().includes(lowerQuery) || template.description?.toLowerCase().includes(lowerQuery) || template.tags?.some(tag => tag.toLowerCase().includes(lowerQuery)) || template.category?.toLowerCase().includes(lowerQuery) ); }); }