Skip to main content
Glama

Postman MCP Generator

by ramborau
mark-message-as-read.js2.27 kB
/** * Function to mark a WhatsApp message as read. * * @param {Object} args - Arguments for marking the message as read. * @param {string} args.message_id - The ID of the incoming message to mark as read. * @returns {Promise<Object>} - The result of the operation to mark the message as read. */ const executeFunction = async ({ message_id }) => { 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`; // Set up the request body const body = JSON.stringify({ messaging_product: "whatsapp", status: "read", message_id: message_id }); // 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: 'PUT', headers, body }); // 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 marking message as read:', error); return { error: `An error occurred while marking the message as read: ${error instanceof Error ? error.message : JSON.stringify(error)}` }; } }; /** * Tool configuration for marking a WhatsApp message as read. * @type {Object} */ const apiTool = { function: executeFunction, definition: { type: 'function', function: { name: 'mark_message_as_read', description: 'Mark a WhatsApp message as read.', parameters: { type: 'object', properties: { message_id: { type: 'string', description: 'The ID of the incoming message to mark as read.' } }, required: ['message_id'] } } } }; 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