Skip to main content
Glama

Postman MCP Generator

by ramborau
send-reply-to-document-message-by-id.js3.29 kB
/** * Function to send a reply to a document message by ID on WhatsApp. * * @param {Object} args - Arguments for sending the reply. * @param {string} args.recipientPhoneNumber - The phone number of the recipient. * @param {string} args.messageId - The message ID of the message you are replying to. * @param {string} args.documentId - The ID of the document object you are replying to. * @param {string} args.documentCaption - The caption for the document to send. * @param {string} args.documentFilename - The filename of the document to send. * @returns {Promise<Object>} - The result of the send reply operation. */ const executeFunction = async ({ recipientPhoneNumber, messageId, documentId, documentCaption, documentFilename }) => { 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 { const url = `${baseUrl}/${version}/${businessPhoneNumberId}/messages`; const body = { messaging_product: "whatsapp", recipient_type: "individual", to: recipientPhoneNumber, context: { message_id: messageId }, type: "document", document: { id: documentId, caption: documentCaption, filename: documentFilename } }; const headers = { 'Content-Type': 'application/json', 'Authorization': `Bearer ${token}` }; const response = await fetch(url, { method: 'POST', headers, body: JSON.stringify(body) }); if (!response.ok) { const errorData = await response.json(); throw new Error(JSON.stringify(errorData)); } const data = await response.json(); return data; } catch (error) { console.error('Error sending reply to document message:', error); return { error: `An error occurred while sending the reply: ${error instanceof Error ? error.message : JSON.stringify(error)}` }; } }; /** * Tool configuration for sending a reply to a document message on WhatsApp. * @type {Object} */ const apiTool = { function: executeFunction, definition: { type: 'function', function: { name: 'send_reply_to_document_message', description: 'Send a reply to a document message by ID on WhatsApp.', parameters: { type: 'object', properties: { recipientPhoneNumber: { type: 'string', description: 'The phone number of the recipient.' }, messageId: { type: 'string', description: 'The message ID of the message you are replying to.' }, documentId: { type: 'string', description: 'The ID of the document object you are replying to.' }, documentCaption: { type: 'string', description: 'The caption for the document to send.' }, documentFilename: { type: 'string', description: 'The filename of the document to send.' } }, required: ['recipientPhoneNumber', 'messageId', 'documentId'] } } } }; 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