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

whatsapp_send_reaction

Send emoji reactions to specific WhatsApp messages using message ID, chat ID, and sender ID parameters to respond to conversations.

Instructions

Send a reaction (emoji) to a specific message.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
messageIdYesID of the message to react to
toYesChat ID where the message is located
senderIdYesID of the original message sender
reactionYesEmoji reaction to send (max 10 characters)

Implementation Reference

  • The ToolHandler implementation for 'whatsapp_send_reaction'. Defines the tool name, description, input schema (JSON Schema format), and the asynchronous handler function. The handler validates input using a Zod schema, logs the action, calls the WSAPI endpoint to send the reaction, logs success, and returns a success response with the message ID.
    export const sendReactionMessage: ToolHandler = { name: 'whatsapp_send_reaction', description: 'Send a reaction (emoji) to a specific message.', inputSchema: { type: 'object', properties: { messageId: { type: 'string', description: 'ID of the message to react to', }, to: { type: 'string', description: 'Chat ID where the message is located', }, senderId: { type: 'string', description: 'ID of the original message sender', }, reaction: { type: 'string', description: 'Emoji reaction to send (max 10 characters)', }, }, required: ['messageId', 'to', 'senderId', 'reaction'], }, handler: async (args: any) => { const input = validateInput(sendReactionMessageSchema, args) as SendReactionMessageInput; logger.info('Sending reaction', { messageId: input.messageId, to: input.to, reaction: input.reaction, }); const result = await wsapiClient.post(`/messages/${input.messageId}/reaction`, { to: input.to, senderId: input.senderId, reaction: input.reaction, }); logger.info('Reaction sent successfully', { messageId: result.id }); return { success: true, messageId: result.id, message: 'Reaction sent successfully', }; }, };
  • Zod schema (sendReactionMessageSchema) used by the tool handler for runtime input validation. Defines strict types for messageId, to (chat ID), senderId (phone number), and reaction (emoji string max 10 chars). Reuses common schemas like messageIdSchema, chatIdSchema, phoneNumberSchema.
    export const sendReactionMessageSchema = z.object({ messageId: messageIdSchema, to: chatIdSchema, senderId: phoneNumberSchema, reaction: z.string().min(1).max(10), // Emoji });
  • src/server.ts:57-76 (registration)
    Registration logic in setupToolHandlers() method. Imports messagingTools (line 15, not shown) which contains the sendReactionMessage tool, and dynamically registers all tools from tool categories into the MCP server's tools Map by name.
    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}`); }); });
  • Helper function validateInput used in the tool handler to perform Zod schema validation on input arguments, throwing detailed errors if invalid.
    export function validateInput<T>(schema: z.ZodSchema<T>, data: unknown): T { const result = schema.safeParse(data); if (!result.success) { const errors = result.error.errors.map(err => `${err.path.join('.')}: ${err.message}`); throw new Error(`Validation failed: ${errors.join(', ')}`); } return result.data; }
  • src/server.ts:15-15 (registration)
    Import of messagingTools object, which exports the sendReactionMessage handler (among others), enabling its registration in the MCP server.
    import { messagingTools } from './tools/messaging.js';

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