whatsapp_send_sticker
Send sticker messages to WhatsApp contacts or groups using either a URL or base64 encoded data. Supports animated stickers, mentions, replies, and forwarding functionality for enhanced communication.
Instructions
Send a sticker message to a WhatsApp contact or group. Can send from URL or base64.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| isAnimated | No | Whether the sticker is animated | |
| isForwarded | No | Whether the message should be marked as forwarded | |
| mentions | No | List of phone numbers to mention | |
| mimeType | Yes | MIME type of the sticker (must be image/webp) | |
| replyTo | No | ID of the message being replied to | |
| stickerBase64 | No | Base64 encoded sticker data (alternative to stickerURL) | |
| stickerURL | No | URL of the sticker to send (alternative to stickerBase64) | |
| to | Yes | Recipient phone number (with @s.whatsapp.net) or group ID (with @g.us) |
Input Schema (JSON Schema)
{
"properties": {
"isAnimated": {
"description": "Whether the sticker is animated",
"optional": true,
"type": "boolean"
},
"isForwarded": {
"description": "Whether the message should be marked as forwarded",
"optional": true,
"type": "boolean"
},
"mentions": {
"description": "List of phone numbers to mention",
"items": {
"type": "string"
},
"optional": true,
"type": "array"
},
"mimeType": {
"description": "MIME type of the sticker (must be image/webp)",
"enum": [
"image/webp"
],
"type": "string"
},
"replyTo": {
"description": "ID of the message being replied to",
"optional": true,
"type": "string"
},
"stickerBase64": {
"description": "Base64 encoded sticker data (alternative to stickerURL)",
"optional": true,
"type": "string"
},
"stickerURL": {
"description": "URL of the sticker to send (alternative to stickerBase64)",
"optional": true,
"type": "string"
},
"to": {
"description": "Recipient phone number (with @s.whatsapp.net) or group ID (with @g.us)",
"type": "string"
}
},
"required": [
"to",
"mimeType"
],
"type": "object"
}
Implementation Reference
- src/tools/messaging-advanced.ts:229-297 (handler)The complete ToolHandler implementation for the 'whatsapp_send_sticker' tool. Defines the tool name, description, input schema (inline), and the async handler function. The handler validates input using an external Zod schema, logs the action, sends the sticker via wsapiClient.post('/messages/sticker', input), logs success, and returns the message ID.export const sendStickerMessage: ToolHandler = { name: 'whatsapp_send_sticker', description: 'Send a sticker message to a WhatsApp contact or group. Can send from URL or base64.', inputSchema: { type: 'object', properties: { to: { type: 'string', description: 'Recipient phone number (with @s.whatsapp.net) or group ID (with @g.us)', }, stickerBase64: { type: 'string', description: 'Base64 encoded sticker data (alternative to stickerURL)', optional: true, }, stickerURL: { type: 'string', description: 'URL of the sticker to send (alternative to stickerBase64)', optional: true, }, mimeType: { type: 'string', enum: ['image/webp'], description: 'MIME type of the sticker (must be image/webp)', }, isAnimated: { type: 'boolean', description: 'Whether the sticker is animated', optional: true, }, mentions: { type: 'array', items: { type: 'string' }, description: 'List of phone numbers to mention', optional: true, }, replyTo: { type: 'string', description: 'ID of the message being replied to', optional: true, }, isForwarded: { type: 'boolean', description: 'Whether the message should be marked as forwarded', optional: true, }, }, required: ['to', 'mimeType'], }, handler: async (args: any) => { const input = validateInput(sendStickerMessageSchema, args) as SendStickerMessageInput; logger.info('Sending sticker message', { to: input.to, mimeType: input.mimeType, isAnimated: input.isAnimated, }); const result = await wsapiClient.post('/messages/sticker', input); logger.info('Sticker message sent successfully', { messageId: result.id }); return { success: true, messageId: result.id, message: 'Sticker message sent successfully', }; }, };
- src/validation/schemas.ts:86-97 (schema)Zod validation schema (sendStickerMessageSchema) used in the tool handler for input validation via validateInput(). Ensures required fields like 'to' and 'mimeType=image/webp', optional base64/URL for sticker (at least one), and other fields like mentions, replyTo.export const sendStickerMessageSchema = z.object({ to: chatIdSchema, stickerBase64: base64Schema.optional(), stickerURL: urlSchema.optional(), mimeType: z.enum(['image/webp']), isAnimated: z.boolean().optional(), mentions: z.array(phoneNumberSchema).optional(), replyTo: messageIdSchema.optional(), isForwarded: z.boolean().optional(), }).refine(data => data.stickerBase64 || data.stickerURL, { message: "Either stickerBase64 or stickerURL must be provided", });
- src/tools/messaging.ts:541-555 (registration)Bundles the advancedMessagingTools (including sendStickerMessage / whatsapp_send_sticker) into the main messagingTools export via spread operator, aggregating all messaging-related tools.import { advancedMessagingTools } from './messaging-advanced.js'; // Export all messaging tools export const messagingTools = { sendTextMessage, sendImageMessage, sendVideoMessage, sendLinkMessage, sendReactionMessage, editMessage, deleteMessage, markMessageAsRead, starMessage, ...advancedMessagingTools, };
- src/server.ts:53-79 (registration)Registers all tools from messagingTools (which includes whatsapp_send_sticker) into the MCP server's tools Map by iterating over tool categories and setting by name. This makes the tool available for MCP list_tools and call_tool requests.private setupToolHandlers(): void { logger.info('Setting up tool handlers'); // Register all tool categories 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}`); }); }); logger.info(`Registered ${this.tools.size} tools`); }
- src/validation/schemas.ts:305-312 (helper)Generic validateInput helper function used in the tool handler to validate arguments against sendStickerMessageSchema before calling the WSAPI.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; }