Skip to main content
Glama
by wsapi-chat

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

NameRequiredDescriptionDefault
isAnimatedNoWhether the sticker is animated
isForwardedNoWhether the message should be marked as forwarded
mentionsNoList of phone numbers to mention
mimeTypeYesMIME type of the sticker (must be image/webp)
replyToNoID of the message being replied to
stickerBase64NoBase64 encoded sticker data (alternative to stickerURL)
stickerURLNoURL of the sticker to send (alternative to stickerBase64)
toYesRecipient 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

  • 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', }; }, };
  • 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", });
  • 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`); }
  • 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; }

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