Skip to main content
Glama

Postman MCP Generator

by ramborau
send-location-message.js3.43 kB
/** * Function to send a location message via WhatsApp. * * @param {Object} args - Arguments for sending the location message. * @param {string} args.RecipientPhoneNumber - The recipient's phone number. * @param {number} args.LocationLatitude - The latitude of the location. * @param {number} args.LocationLongitude - The longitude of the location. * @param {string} args.LocationName - The name of the location. * @param {string} args.LocationAddress - The address of the location. * @returns {Promise<Object>} - The result of the send location message request. */ const executeFunction = async ({ RecipientPhoneNumber, LocationLatitude, LocationLongitude, LocationName, LocationAddress }) => { const baseUrl = '<API_URL>'; // will be provided by the user const token = process.env.BOTPE_MCP_API_KEY; const version = '<Version>'; // will be provided by the user const businessPhoneNumberId = '<PHONE_NUMBER_ID>'; // will be provided by the user try { // Construct the URL for the API request const url = `${baseUrl}/${version}/${businessPhoneNumberId}/messages`; // Create the message payload const payload = { messaging_product: "whatsapp", recipient_type: "individual", to: RecipientPhoneNumber, type: "location", location: { latitude: LocationLatitude, longitude: LocationLongitude, name: LocationName, address: LocationAddress } }; // Set up headers for the request const headers = { 'Content-Type': 'application/json', 'Authorization': `Bearer ${token}` }; // Perform the fetch request const response = await fetch(url, { method: 'POST', headers, body: JSON.stringify(payload) }); // Check if the response was successful if (!response.ok) { const errorData = await response.json(); throw new Error(JSON.stringify(errorData)); } // Parse and return the response data const data = await response.json(); return data; } catch (error) { console.error('Error sending location message:', error); return { error: `An error occurred while sending the location message: ${error instanceof Error ? error.message : JSON.stringify(error)}` }; } }; /** * Tool configuration for sending location messages via WhatsApp. * @type {Object} */ const apiTool = { function: executeFunction, definition: { type: 'function', function: { name: 'send_location_message', description: 'Send a location message via WhatsApp.', parameters: { type: 'object', properties: { RecipientPhoneNumber: { type: 'string', description: 'The recipient\'s phone number.' }, LocationLatitude: { type: 'number', description: 'The latitude of the location.' }, LocationLongitude: { type: 'number', description: 'The longitude of the location.' }, LocationName: { type: 'string', description: 'The name of the location.' }, LocationAddress: { type: 'string', description: 'The address of the location.' } }, required: ['RecipientPhoneNumber', 'LocationLatitude', 'LocationLongitude', 'LocationName', 'LocationAddress'] } } } }; export { apiTool };

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/ramborau/botpe-mcp-2'

If you have feedback or need assistance with the MCP directory API, please join our Discord server