Skip to main content
Glama
wsapi-chat
by wsapi-chat

whatsapp_subscribe_contact_presence

Monitor a WhatsApp contact's online status and availability by subscribing to real-time presence updates using their contact ID.

Instructions

Subscribe to presence updates for a specific contact.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contactIdYesContact ID (phone number with @s.whatsapp.net)

Implementation Reference

  • The complete ToolHandler implementation for 'whatsapp_subscribe_contact_presence', defining the input schema, description, and handler logic that subscribes to presence updates via WSAPI.
    export const subscribeToContactPresence: ToolHandler = { name: 'whatsapp_subscribe_contact_presence', description: 'Subscribe to presence updates for a specific contact.', inputSchema: { type: 'object', properties: { contactId: { type: 'string', description: 'Contact ID (phone number with @s.whatsapp.net)', }, }, required: ['contactId'], }, handler: async (args: any) => { const input = validateInput(getContactSchema, args); logger.info('Subscribing to contact presence', { contactId: input.contactId }); await wsapiClient.post(`/contacts/${input.contactId}/presence`, {}); logger.info('Subscribed to contact presence successfully', { contactId: input.contactId }); return { success: true, message: 'Successfully subscribed to contact presence updates', }; }, };
  • src/server.ts:57-76 (registration)
    Registers all tools from contactTools (which includes whatsapp_subscribe_contact_presence) by adding them to the server's tools Map.
    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}`); }); });
  • Local registration of the subscribeToContactPresence tool within the contactTools export object, which is then imported into server.ts.
    export const contactTools = { getContacts, getContact, createContact, updateContact, getContactPicture, getContactBusinessProfile, subscribeToContactPresence, };
  • Input schema definition requiring a contactId string for the tool.
    inputSchema: { type: 'object', properties: { contactId: { type: 'string', description: 'Contact ID (phone number with @s.whatsapp.net)', }, }, required: ['contactId'], },

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/wsapi-chat/wsapi-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server