waha_subscribe_presence
Monitor real-time online/offline status for WhatsApp chats to track contact availability and engagement patterns.
Instructions
Subscribe to presence updates for a chat.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chatId | Yes | Chat ID (format: number@c.us) |
Implementation Reference
- src/index.ts:1001-1013 (registration)Tool registration and schema definition in the ListTools response. Defines name, description, and input schema requiring chatId.name: "waha_subscribe_presence", description: "Subscribe to presence updates for a chat.", inputSchema: { type: "object", properties: { chatId: { type: "string", description: "Chat ID (format: number@c.us)", }, }, required: ["chatId"], }, },
- src/index.ts:2610-2627 (handler)Primary handler function for the tool. Validates input, calls the WAHA client method, and returns formatted success response.private async handleSubscribePresence(args: any) { const chatId = args.chatId; if (!chatId) { throw new Error("chatId is required"); } await this.wahaClient.subscribePresence(chatId); return { content: [ { type: "text", text: `Successfully subscribed to presence updates for ${chatId}.`, }, ], }; }
- src/client/waha-client.ts:1411-1421 (helper)WAHAClient helper method that performs the actual HTTP POST request to the WAHA API to subscribe to presence updates for the specified chat.async subscribePresence(chatId: string): Promise<void> { if (!chatId) { throw new WAHAError("chatId is required"); } const endpoint = `/api/${this.session}/presence/${encodeURIComponent(chatId)}/subscribe`; await this.request<void>(endpoint, { method: "POST", }); }
- src/index.ts:1153-1154 (handler)Tool dispatcher in the CallToolRequest handler switch statement that routes to the specific handler function.case "waha_set_presence": return await this.handleSetPresence(args);