whatsapp_send_location
Send location coordinates to WhatsApp contacts or groups to share real-time positions or meeting points using latitude and longitude data.
Instructions
Send a location message to a WhatsApp contact or group.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| to | Yes | Recipient phone number (with @s.whatsapp.net) or group ID (with @g.us) | |
| latitude | Yes | Latitude coordinate | |
| longitude | Yes | Longitude coordinate | |
| name | No | Name of the location (max 1000 characters) | |
| address | No | Address of the location (max 1000 characters) | |
| url | No | URL related to the location (e.g., Google Maps link) |
Implementation Reference
- src/tools/messaging-advanced.ts:340-360 (handler)The handler function that validates the input using sendLocationMessageSchema and sends the location message via wsapiClient.post('/messages/location', input). Returns success with message ID.handler: async (args: any) => { const input = validateInput(sendLocationMessageSchema, args) as SendLocationMessageInput; logger.info('Sending location message', { to: input.to, latitude: input.latitude, longitude: input.longitude, hasName: !!input.name, hasAddress: !!input.address, }); const result = await wsapiClient.post('/messages/location', input); logger.info('Location message sent successfully', { messageId: result.id }); return { success: true, messageId: result.id, message: 'Location message sent successfully', }; },
- src/validation/schemas.ts:99-106 (schema)Zod schema used for input validation in the whatsapp_send_location handler. Defines properties like to, latitude, longitude, etc.export const sendLocationMessageSchema = z.object({ to: chatIdSchema, latitude: z.number().min(-90).max(90), longitude: z.number().min(-180).max(180), name: z.string().max(1000).optional(), address: z.string().max(1000).optional(), url: urlSchema.optional(), });
- src/server.ts:67-76 (registration)Registration loop in setupToolHandlers() that adds all tools from messagingTools (which includes whatsapp_send_location) to the server's tools Map.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}`); }); });
- src/validation/schemas.ts:322-322 (schema)TypeScript type definition for the input parameters inferred from the Zod schema.export type SendLocationMessageInput = z.infer<typeof sendLocationMessageSchema>;
- src/tools/messaging-advanced.ts:300-361 (registration)Full ToolHandler definition including name, description, inputSchema (for MCP), and handler reference. Exported and included in advancedMessagingTools.export const sendLocationMessage: ToolHandler = { name: 'whatsapp_send_location', description: 'Send a location 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)', }, latitude: { type: 'number', minimum: -90, maximum: 90, description: 'Latitude coordinate', }, longitude: { type: 'number', minimum: -180, maximum: 180, description: 'Longitude coordinate', }, name: { type: 'string', description: 'Name of the location (max 1000 characters)', optional: true, }, address: { type: 'string', description: 'Address of the location (max 1000 characters)', optional: true, }, url: { type: 'string', description: 'URL related to the location (e.g., Google Maps link)', optional: true, }, }, required: ['to', 'latitude', 'longitude'], }, handler: async (args: any) => { const input = validateInput(sendLocationMessageSchema, args) as SendLocationMessageInput; logger.info('Sending location message', { to: input.to, latitude: input.latitude, longitude: input.longitude, hasName: !!input.name, hasAddress: !!input.address, }); const result = await wsapiClient.post('/messages/location', input); logger.info('Location message sent successfully', { messageId: result.id }); return { success: true, messageId: result.id, message: 'Location message sent successfully', }; }, };