Skip to main content
Glama
by wsapi-chat

whatsapp_send_contact

Send contact information via vCard to WhatsApp contacts or groups, enabling quick sharing of contact details within conversations.

Instructions

Send a contact (vCard) message to a WhatsApp contact or group.

Input Schema

NameRequiredDescriptionDefault
displayNameNoDisplay name for the contact (alternative to vCard)
isForwardedNoWhether the message should be marked as forwarded
mentionsNoList of phone numbers to mention
replyToNoID of the message being replied to
toYesRecipient phone number (with @s.whatsapp.net) or group ID (with @g.us)
vCardNoRaw vCard string (alternative to displayName)

Input Schema (JSON Schema)

{ "properties": { "displayName": { "description": "Display name for the contact (alternative to vCard)", "optional": true, "type": "string" }, "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" }, "replyTo": { "description": "ID of the message being replied to", "optional": true, "type": "string" }, "to": { "description": "Recipient phone number (with @s.whatsapp.net) or group ID (with @g.us)", "type": "string" }, "vCard": { "description": "Raw vCard string (alternative to displayName)", "optional": true, "type": "string" } }, "required": [ "to" ], "type": "object" }

Implementation Reference

  • The complete ToolHandler for 'whatsapp_send_contact', defining name, description, input schema, and handler logic that validates input using sendContactMessageSchema and sends via wsapiClient.post('/messages/contact').
    export const sendContactMessage: ToolHandler = { name: 'whatsapp_send_contact', description: 'Send a contact (vCard) message to a WhatsApp contact or group.', inputSchema: { type: 'object', properties: { to: { type: 'string', description: 'Recipient phone number (with @s.whatsapp.net) or group ID (with @g.us)', }, displayName: { type: 'string', description: 'Display name for the contact (alternative to vCard)', optional: true, }, vCard: { type: 'string', description: 'Raw vCard string (alternative to displayName)', 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'], }, handler: async (args: any) => { const input = validateInput(sendContactMessageSchema, args) as SendContactMessageInput; logger.info('Sending contact message', { to: input.to, hasDisplayName: !!input.displayName, hasVCard: !!input.vCard, }); const result = await wsapiClient.post('/messages/contact', input); logger.info('Contact message sent successfully', { messageId: result.id }); return { success: true, messageId: result.id, message: 'Contact message sent successfully', }; }, };
  • Zod input validation schema (sendContactMessageSchema) used in the handler's validateInput call, ensuring required fields like 'to' and either 'displayName' or 'vCard'.
    export const sendContactMessageSchema = z.object({ to: chatIdSchema, displayName: z.string().min(1).max(255).optional(), vCard: z.string().min(1).optional(), mentions: z.array(phoneNumberSchema).optional(), replyTo: messageIdSchema.optional(), isForwarded: z.boolean().optional(), }).refine(data => data.displayName || data.vCard, { message: "Either displayName or vCard must be provided", });
  • Registration of the tool via import and spread of advancedMessagingTools into the main messagingTools export, which is later included in the server's all 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:15-58 (registration)
    Final server-side registration where messagingTools (including whatsapp_send_contact) is included in the tools registry.
    import { messagingTools } from './tools/messaging.js'; import { contactTools } from './tools/contacts.js'; import { groupTools } from './tools/groups.js'; import { chatTools } from './tools/chats.js'; import { sessionTools } from './tools/session.js'; import { instanceTools } from './tools/instance.js'; import { accountTools } from './tools/account.js'; const logger = createLogger('mcp-server'); export interface ToolHandler { name: string; description: string; inputSchema: any; handler: (args: any) => Promise<any>; } export class WSAPIMCPServer { private server: Server; private tools: Map<string, ToolHandler> = new Map(); constructor() { this.server = new Server( { name: 'wsapi-mcp-server', version: '1.0.0', }, { capabilities: { tools: {}, }, } ); this.setupToolHandlers(); this.setupServerHandlers(); } private setupToolHandlers(): void { logger.info('Setting up tool handlers'); // Register all tool categories const toolCategories = [ messagingTools,

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