whatsapp_archive_chat
Archive or unarchive WhatsApp chats to organize your conversations by hiding or restoring them from the main chat list.
Instructions
Archive or unarchive a chat.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| archived | Yes | Whether to archive or unarchive | |
| chatId | Yes | Chat ID |
Implementation Reference
- src/tools/chats.ts:52-68 (handler)Core ToolHandler implementation for 'whatsapp_archive_chat'. Defines the tool name, description, input schema, and the async handler function that validates input and performs the archive/unarchive operation via wsapiClient.put.export const archiveChat: ToolHandler = { name: 'whatsapp_archive_chat', description: 'Archive or unarchive a chat.', inputSchema: { type: 'object', properties: { chatId: { type: 'string', description: 'Chat ID' }, archived: { type: 'boolean', description: 'Whether to archive or unarchive' }, }, required: ['chatId', 'archived'], }, handler: async (args: any) => { const input = validateInput(updateChatArchiveSchema, args); await wsapiClient.put(`/chats/${input.chatId}/archive`, { archived: input.archived }); return { success: true, message: `Chat ${input.archived ? 'archived' : 'unarchived'} successfully` }; }, };
- src/validation/schemas.ts:249-252 (schema)Zod validation schema used in the handler for input validation: requires chatId (union of phone or group ID) and archived (boolean).export const updateChatArchiveSchema = z.object({ chatId: chatIdSchema, archived: z.boolean(), });
- src/server.ts:57-75 (registration)Tool registration logic in WSAPIMCPServer.setupToolHandlers(). Includes chatTools (containing whatsapp_archive_chat) in toolCategories array and registers each tool by name in the tools Map for MCP server handling.const toolCategories = [ messagingTools, contactTools, groupTools, chatTools, sessionTools, instanceTools, accountTools, ]; toolCategories.forEach(category => { Object.values(category).forEach(tool => { if (this.tools.has(tool.name)) { logger.warn(`Tool ${tool.name} already registered, skipping`); return; } this.tools.set(tool.name, tool); logger.debug(`Registered tool: ${tool.name}`); });
- src/server.ts:18-18 (registration)Import of chatTools object from src/tools/chats.ts, which exports the archiveChat handler among others, enabling its inclusion in server tool registration.import { chatTools } from './tools/chats.js';