waha_pin_message
Pin important messages to the top of WhatsApp chats for easy reference, with customizable duration settings.
Instructions
Pin a message in a chat. Pinned messages appear at the top of the chat.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chatId | Yes | Chat ID (format: number@c.us) | |
| messageId | Yes | Message ID to pin | |
| duration | No | Pin duration in seconds (default: 86400 = 24 hours) |
Implementation Reference
- src/index.ts:1407-1434 (handler)MCP server handler function that processes the waha_pin_message tool call, validates inputs, calls the WAHA client pinMessage method, and returns success response.private async handlePinMessage(args: any) { const chatId = args.chatId; const messageId = args.messageId; const duration = args.duration || 86400; // Default 24 hours if (!chatId) { throw new Error("chatId is required"); } if (!messageId) { throw new Error("messageId is required"); } await this.wahaClient.pinMessage({ chatId, messageId, duration, }); return { content: [ { type: "text", text: `Successfully pinned message ${messageId} in chat ${chatId}.\nDuration: ${duration} seconds`, }, ], }; }
- src/index.ts:217-237 (schema)Tool schema definition including name, description, and input schema returned by ListToolsRequestSchema handler.name: "waha_pin_message", description: "Pin a message in a chat. Pinned messages appear at the top of the chat.", inputSchema: { type: "object", properties: { chatId: { type: "string", description: "Chat ID (format: number@c.us)", }, messageId: { type: "string", description: "Message ID to pin", }, duration: { type: "number", description: "Pin duration in seconds (default: 86400 = 24 hours)", default: 86400, }, }, required: ["chatId", "messageId"], },
- src/index.ts:1063-1064 (registration)Registration of the waha_pin_message tool in the CallToolRequestSchema switch statement, dispatching to the handler.case "waha_pin_message": return await this.handlePinMessage(args);
- src/client/waha-client.ts:361-389 (helper)WAHAClient helper method that makes the HTTP POST request to the WAHA API to pin the message.async pinMessage(params: { chatId: string; messageId: string; duration?: number; }): Promise<void> { const { chatId, messageId, duration } = params; if (!chatId) { throw new WAHAError("chatId is required"); } if (!messageId) { throw new WAHAError("messageId is required"); } const queryParams: Record<string, any> = {}; if (duration !== undefined) { queryParams.duration = duration; } const queryString = this.buildQueryString(queryParams); const endpoint = `/api/${this.session}/chats/${encodeURIComponent( chatId )}/messages/${encodeURIComponent(messageId)}/pin${queryString}`; await this.request<void>(endpoint, { method: "POST", }); }