### Install Dependencies and Run Tools (npm) Source: https://github.com/ramborau/botpe-mcp-2/blob/main/CLAUDE.md Commands for installing project dependencies and listing all available WhatsApp API tools using npm scripts. These are essential for development and understanding the project's capabilities. ```bash # Install dependencies npm install # List all available tools (40+ WhatsApp API tools) npm run list-tools # or node index.js tools ``` -------------------------------- ### Start MCP Server (Node.js) Source: https://github.com/ramborau/botpe-mcp-2/blob/main/CLAUDE.md Instructions for starting the MCP server in different modes: default stdio, with Streamable HTTP support, or with Server-Sent Events (SSE) support. These commands are used to run the server for integration and testing. ```bash # Start MCP server in stdio mode (default) node mcpServer.js # Start server with Streamable HTTP support (port 3001) node mcpServer.js --streamable-http # Start server with Server-Sent Events (SSE) support (port 3001) node mcpServer.js --sse ``` -------------------------------- ### Build and Run Docker Image for MCP Server in Bash Source: https://context7.com/ramborau/botpe-mcp-2/llms.txt Demonstrates building a Docker image for the MCP server and running it. Supports running with environment files or inline environment variables. Requires Docker to be installed. ```bash # Build Docker image docker build -t botpe-mcp-server . # Run with environment file docker run -i --rm --env-file=.env botpe-mcp-server # Run with inline environment variables docker run -i --rm \ -e BOTPE_MCP_API_KEY=your_api_key \ botpe-mcp-server ``` -------------------------------- ### Initialize BotPe MCP Server in Different Transport Modes Source: https://context7.com/ramborau/botpe-mcp-2/llms.txt This snippet demonstrates how to start the MCP server in three distinct transport modes: stdio (default, for Claude Desktop), Streamable HTTP (exposing a POST /mcp endpoint), and Server-Sent Events (SSE, exposing GET /sse and POST /messages endpoints). Configuration is handled via environment variables, with an optional PORT setting. ```bash # stdio mode (default) - for Claude Desktop integration node mcpServer.js # Streamable HTTP mode - exposes POST /mcp endpoint on port 3001 node mcpServer.js --streamable-http # Server-Sent Events mode - exposes GET /sse and POST /messages endpoints node mcpServer.js --sse # .env file required BOTPE_MCP_API_KEY=your_api_key_here # Environment variables export PORT=3001 # Optional, defaults to 3001 for HTTP/SSE modes ``` -------------------------------- ### Install Dependencies using npm Source: https://github.com/ramborau/botpe-mcp-2/blob/main/README.md Installs all necessary project dependencies using npm. Ensure Node.js and npm are installed and accessible in your PATH. ```sh npm install ``` -------------------------------- ### Claude Desktop MCP Server Configuration (JSON) Source: https://github.com/ramborau/botpe-mcp-2/blob/main/CLAUDE.md Example JSON configuration for integrating the BotPe MCP server with Claude Desktop. This specifies the command and arguments required to launch the server within the Claude Desktop environment. ```json { "mcpServers": { "botpe-mcp": { "command": "/absolute/path/to/node", "args": ["/absolute/path/to/mcpServer.js"] } } } ``` -------------------------------- ### Configure MCP Server in Claude Desktop Source: https://github.com/ramborau/botpe-mcp-2/blob/main/README.md Example JSON configuration for adding an MCP server to Claude Desktop. It specifies the command to execute (Node.js) and its arguments (the path to the mcpServer.js script). ```json { "mcpServers": { "": { "command": "", "args": [""] } } } ``` -------------------------------- ### List Available Tools via npm Script or Node Execution Source: https://context7.com/ramborau/botpe-mcp-2/llms.txt This command-line snippet shows how to list all the tools discovered and registered by the BotPe MCP Server. It can be executed using an npm script (`npm run list-tools`) or directly via Node.js (`node index.js tools`). An example of the expected output format, detailing tool names, descriptions, and parameters, is also provided. ```bash npm run list-tools # or node index.js tools # Example output: # Available Tools: # send_text_message # Description: Send a text message via WhatsApp. # Parameters: # - recipientPhoneNumber: The phone number of the recipient. # - messageContent: The content of the text message to be sent. ``` -------------------------------- ### Minimal Dockerfile for Node.js Project Source: https://github.com/ramborau/botpe-mcp-2/blob/main/README.md A minimal Dockerfile using a Node.js Alpine base image for building and running the project. It installs dependencies, copies project files, and sets the entrypoint to start the mcpServer.js script. ```dockerfile FROM node:22.12-alpine AS builder WORKDIR /app COPY package.json package-lock.json ./ RUN npm install COPY . . ENTRYPOINT ["node", "mcpServer.js"] ``` -------------------------------- ### Discover and Load Tools for BotPe MCP Server Source: https://context7.com/ramborau/botpe-mcp-2/llms.txt This code snippet illustrates the dynamic tool discovery system within the BotPe MCP Server. It imports a `discoverTools` function to scan the filesystem for available tools, registering them with the MCP protocol. An example of a discovered tool's structure, including its function, definition (name, description, parameters), and path, is provided. The system also handles automatic name deduplication. ```javascript // lib/tools.js - Discover and load all tools import { discoverTools } from './lib/tools.js'; // Returns array of tool objects with definitions and functions const tools = await discoverTools(); // Example tool structure const exampleTool = { function: async ({ recipientPhoneNumber, messageContent }) => { // Execute API call return { status: 'success', message_id: '12345' }; }, definition: { type: 'function', function: { name: 'send_text_message', description: 'Send a text message via WhatsApp.', parameters: { type: 'object', properties: { recipientPhoneNumber: { type: 'string', description: 'The phone number of the recipient.' }, messageContent: { type: 'string', description: 'The content of the text message to be sent.' } }, required: ['recipientPhoneNumber', 'messageContent'] } } }, path: 'botpe-mcp/api-documentation/send-text-message.js' }; // Automatic name deduplication if conflicts exist // If duplicate names found, appends _2, _3, etc. ``` -------------------------------- ### Run Server with Server-Sent Events (SSE) Source: https://github.com/ramborau/botpe-mcp-2/blob/main/README.md Starts the server with Server-Sent Events (SSE) support, enabling the `/sse` and `/messages` endpoints. This is suitable for applications that need to push real-time updates from the server to the client. ```sh node mcpServer.js --sse ``` -------------------------------- ### Setup MCP Server Handlers in JavaScript Source: https://context7.com/ramborau/botpe-mcp-2/llms.txt Configures request handlers for listing tools and executing tool calls using the MCP protocol. It validates required parameters and handles potential API errors. Requires MCP library for server and request schemas. ```javascript // mcpServer.js - Setup request handlers async function setupServerHandlers(server, tools) { // Handle tool listing requests server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: await transformTools(tools) })); // Handle tool execution requests server.setRequestHandler(CallToolRequestSchema, async (request) => { const toolName = request.params.name; const tool = tools.find((t) => t.definition.function.name === toolName); if (!tool) { throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${toolName}`); } const args = request.params.arguments; const requiredParameters = tool.definition?.function?.parameters?.required || []; // Validate required parameters for (const requiredParameter of requiredParameters) { if (!(requiredParameter in args)) { throw new McpError( ErrorCode.InvalidParams, `Missing required parameter: ${requiredParameter}` ); } } try { const result = await tool.function(args); return { content: [ { type: "text", text: JSON.stringify(result, null, 2) } ] }; } catch (error) { console.error('[Error] Failed to fetch data:', error); throw new McpError( ErrorCode.InternalError, `API error: ${error.message}` ); } }); } // Example: Start server in stdio mode async function setupStdio(tools) { const server = new Server( { name: "generated-mcp-server", version: "0.1.0" }, { capabilities: { tools: {} } } ); server.onerror = (error) => console.error('[Error]', error); await setupServerHandlers(server, tools); process.on('SIGINT', async () => { await server.close(); process.exit(0); }); const transport = new StdioServerTransport(); await server.connect(transport); } ``` -------------------------------- ### Example Environment Variable Usage in Tool File Source: https://github.com/ramborau/botpe-mcp-2/blob/main/README.md Demonstrates how environment variables, like API keys, are accessed within generated tool files. These variables are typically set in a .env file and are crucial for API authentication. ```javascript // environment variables are used inside of each tool file const apiKey = process.env.ACME_API_KEY; ``` -------------------------------- ### Docker Compose Configuration for MCP Server in YAML Source: https://context7.com/ramborau/botpe-mcp-2/llms.txt Defines a Docker Compose setup for the MCP server, specifying the build context, image name, container name, and environment file. Suitable for multi-container Docker applications. ```yaml # docker-compose.yml version: '3.8' services: mcp-server: build: . image: botpe-mcp-server container_name: botpe-mcp stdin_open: true tty: true env_file: - .env restart: unless-stopped ``` -------------------------------- ### Get Absolute Path to mcpServer.js Source: https://github.com/ramborau/botpe-mcp-2/blob/main/README.md Determines the absolute file system path for the 'mcpServer.js' file. This path is necessary when configuring MCP clients or external tools that need to directly execute the server script. ```sh realpath mcpServer.js ``` -------------------------------- ### Get Node Executable Path Source: https://github.com/ramborau/botpe-mcp-2/blob/main/README.md Retrieves the absolute path to the currently active Node.js executable. This is often required for configuring external applications to use a specific Node.js version, especially for MCP servers that rely on Node.js features like 'fetch'. ```sh which node ``` -------------------------------- ### Send Interactive Button Message API Source: https://context7.com/ramborau/botpe-mcp-2/llms.txt This API endpoint allows you to send messages with interactive reply buttons, enabling users to make selections directly within the chat. It's ideal for guided conversations and quick responses. ```APIDOC ## POST /messages ### Description Send messages with interactive reply buttons for user selection. ### Method POST ### Endpoint `///messages` ### Parameters #### Path Parameters - **Version** (string) - Required - The API version. - **PHONE_NUMBER_ID** (string) - Required - The business phone number ID. #### Query Parameters None #### Request Body - **recipientPhoneNumber** (string) - Required - The phone number of the recipient. - **buttonText** (string) - Required - The main text content of the message. - **buttons** (array) - Required - An array of button objects, each containing 'id' and 'title'. - **id** (string) - Required - The unique identifier for the button. - **title** (string) - Required - The text displayed on the button. ### Request Example ```json { "recipientPhoneNumber": "+1234567890", "buttonText": "Would you like to schedule an appointment?", "buttons": [ { "id": "yes_schedule", "title": "Yes, Schedule" }, { "id": "no_thanks", "title": "No Thanks" }, { "id": "more_info", "title": "More Info" } ] } ``` ### Response #### Success Response (200) - **messaging_product** (string) - The messaging product used (e.g., "whatsapp"). - **contacts** (array) - Information about the contact(s) the message was sent to. - **input** (string) - The input phone number. - **wa_id** (string) - The WhatsApp ID of the contact. - **messages** (array) - Information about the sent message(s). - **id** (string) - The unique ID of the message. #### Response Example ```json { "messaging_product": "whatsapp", "contacts": [{ "input": "+1234567890", "wa_id": "1234567890" }], "messages": [{ "id": "wamid.HBgNMTIzNDU2Nzg5MAA=" }] } ``` ``` -------------------------------- ### Configure Claude Desktop Docker MCP Server in JSON Source: https://context7.com/ramborau/botpe-mcp-2/llms.txt Integrates the MCP server running in Docker with Claude Desktop. It specifies 'docker' as the command and provides arguments to run the container, including mounting environment files. Requires Docker and the MCP server image to be available. ```json { "mcpServers": { "botpe-whatsapp-docker": { "command": "docker", "args": ["run", "-i", "--rm", "--env-file=/absolute/path/to/.env", "botpe-mcp-server"] } } } ``` -------------------------------- ### Configure Claude Desktop MCP Server in JSON Source: https://context7.com/ramborau/botpe-mcp-2/llms.txt Sets up the MCP server for the Claude Desktop application by specifying the command to run the server script and its arguments. Requires absolute paths for the Node.js executable and the server script. ```json // Claude Desktop Config - ~/.config/claude/config.json (macOS/Linux) // or %APPDATA%\claude\config.json (Windows) { "mcpServers": { "botpe-whatsapp": { "command": "/usr/local/bin/node", "args": ["/absolute/path/to/mcpServer.js"], "env": { "BOTPE_MCP_API_KEY": "your_api_key_here" } } } } ``` -------------------------------- ### Docker Deployment Commands Source: https://github.com/ramborau/botpe-mcp-2/blob/main/CLAUDE.md Commands for building a Docker image for the BotPe MCP server and running it using Docker. This includes building the image and executing it with an environment file for configuration. ```bash # Build Docker image docker build -t botpe-mcp-server . # Run with Docker (requires .env file) docker run -i --rm --env-file=.env botpe-mcp-server ``` -------------------------------- ### List Available Tools via CLI Source: https://github.com/ramborau/botpe-mcp-2/blob/main/README.md Lists all generated tools, including their descriptions and parameters, from the project. This command is useful for understanding the available functionalities and their usage requirements. ```sh node index.js tools ``` -------------------------------- ### Run Server with Streamable HTTP Source: https://github.com/ramborau/botpe-mcp-2/blob/main/README.md Launches the server with Streamable HTTP support enabled, making the `/mcp` endpoint available. This command is used for specific integration needs requiring streamable HTTP communication. ```sh node mcpServer.js --streamable-http ``` -------------------------------- ### Individual Tool File Structure (JavaScript) Source: https://github.com/ramborau/botpe-mcp-2/blob/main/CLAUDE.md Defines the standard pattern for individual tool files within the project. Each tool exports an `apiTool` object containing the executable function and its MCP-compatible definition (schema). It also shows how to access environment variables for API keys. ```javascript const executeFunction = async ({ param1, param2 }) => { const token = process.env.BOTPE_MCP_API_KEY; // API call logic }; const apiTool = { function: executeFunction, definition: { type: 'function', function: { name: 'tool_name', description: 'Tool description', parameters: { /* JSON Schema */ } } } }; export { apiTool }; ``` -------------------------------- ### Configure Claude Desktop with Docker Server Source: https://github.com/ramborau/botpe-mcp-2/blob/main/README.md Configures Claude Desktop to use a Dockerized server. This involves adding server details, including the command and arguments to run the Docker container, to the developer settings. Ensure environment variables are set in a .env file. ```json { "mcpServers": { "": { "command": "docker", "args": ["run", "-i", "--rm", "--env-file=.env", ""] } } } ``` -------------------------------- ### Build Docker Image for Production Source: https://github.com/ramborau/botpe-mcp-2/blob/main/README.md Builds a Docker image for the project, tagged with a specified server name. This is the first step for deploying the application in a production environment using Docker. ```sh docker build -t . ``` -------------------------------- ### Run Server with Stdio (Standard Input/Output) Source: https://github.com/ramborau/botpe-mcp-2/blob/main/README.md Executes the server in Stdio mode, utilizing standard input and output. This mode is ideal for command-line interface (CLI) tools or programmatic integrations where data is passed via stdin and stdout. ```sh node mcpServer.js ``` -------------------------------- ### Check Node.js Version Source: https://github.com/ramborau/botpe-mcp-2/blob/main/README.md Displays the version of the Node.js runtime currently in use. It's important to ensure this version meets the project's requirements (e.g., v18+ for 'fetch' API support). ```sh node --version ``` -------------------------------- ### Send WhatsApp Poll Message Tool (JavaScript) Source: https://context7.com/ramborau/botpe-mcp-2/llms.txt This JavaScript code defines a new tool for the BotPe MCP Server to send poll messages via the WhatsApp API. It includes the function to execute the API call, the tool definition adhering to the required schema, and instructions for registering it within the server's tool paths. Dependencies include the 'fetch' API. ```javascript // Step 1: Create new tool file // tools/botpe-mcp/api-documentation/send-poll-message.js const executeFunction = async ({ recipientPhoneNumber, question, options }) => { const baseUrl = ''; const version = ''; const businessPhoneNumberId = ''; const token = process.env.BOTPE_MCP_API_KEY; try { const url = `${baseUrl}/${version}/${businessPhoneNumberId}/messages`; const response = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${token}` }, body: JSON.stringify({ messaging_product: "whatsapp", recipient_type: "individual", to: recipientPhoneNumber, type: "interactive", interactive: { type: "poll", body: { text: question }, action: { poll: { options: options.map(opt => ({ text: opt })) } } } }) }); if (!response.ok) { const errorData = await response.json(); throw new Error(JSON.stringify(errorData)); } return await response.json(); } catch (error) { return { error: `An error occurred: ${error.message}` }; } }; const apiTool = { function: executeFunction, definition: { type: 'function', function: { name: 'send_poll_message', description: 'Send a poll message via WhatsApp.', parameters: { type: 'object', properties: { recipientPhoneNumber: { type: 'string', description: 'The phone number of the recipient.' }, question: { type: 'string', description: 'The poll question.' }, options: { type: 'array', items: { type: 'string' }, description: 'Array of poll options.' } }, required: ['recipientPhoneNumber', 'question', 'options'] } } } }; export { apiTool }; ``` ```javascript // Step 2: Register in tools/paths.js export const toolPaths = [ 'botpe-mcp/api-documentation/send-text-message.js', 'botpe-mcp/api-documentation/send-image-message-by-url.js', // ... existing tools ... 'botpe-mcp/api-documentation/send-poll-message.js' // Add new tool ]; // Step 3: Restart server - new tool automatically discovered // node mcpServer.js // Step 4: Verify tool is available // npm run list-tools ``` -------------------------------- ### Send Contact Message API Source: https://context7.com/ramborau/botpe-mcp-2/llms.txt This API endpoint allows you to send contact information to users in a vCard format. It includes fields for name, phone numbers, emails, addresses, and organization details. ```APIDOC ## POST /messages ### Description Send contact information with full vCard details including name, phone numbers, emails, addresses, and organization. ### Method POST ### Endpoint `///messages` ### Parameters #### Path Parameters - **Version** (string) - Required - The API version. - **PHONE_NUMBER_ID** (string) - Required - The business phone number ID. #### Query Parameters None #### Request Body - **RecipientPhoneNumber** (string) - Required - The phone number of the recipient. - **contact** (object) - Required - The contact object containing vCard details. - **addresses** (array) - Optional - Array of address objects. - **street** (string) - Optional - Street address. - **city** (string) - Optional - City. - **state** (string) - Optional - State/Province. - **zip** (string) - Optional - Postal/ZIP code. - **country** (string) - Optional - Country name. - **country_code** (string) - Optional - Country code (e.g., "us"). - **type** (string) - Optional - Type of address (e.g., "WORK", "HOME"). - **birthday** (string) - Optional - Birthday in YYYY-MM-DD format. - **emails** (array) - Optional - Array of email objects. - **email** (string) - Optional - Email address. - **type** (string) - Optional - Type of email (e.g., "WORK", "HOME"). - **name** (object) - Required - Name object. - **formatted_name** (string) - Required - Full name as it should be displayed. - **first_name** (string) - Optional - First name. - **last_name** (string) - Optional - Last name. - **middle_name** (string) - Optional - Middle name. - **suffix** (string) - Optional - Name suffix (e.g., "Jr."). - **prefix** (string) - Optional - Name prefix (e.g., "Mr."). - **org** (object) - Optional - Organization object. - **company** (string) - Optional - Company name. - **department** (string) - Optional - Department name. - **title** (string) - Optional - Job title. - **phones** (array) - Optional - Array of phone number objects. - **phone** (string) - Optional - Phone number. - **type** (string) - Optional - Type of phone number (e.g., "WORK", "HOME", "CELL"). - **wa_id** (string) - Optional - WhatsApp ID associated with the phone number. - **urls** (array) - Optional - Array of URL objects. - **url** (string) - Optional - URL. - **type** (string) - Optional - Type of URL (e.g., "WORK", "HOME"). ### Request Example ```json { "RecipientPhoneNumber": "+1234567890", "contact": { "addresses": [ { "street": "123 Main St", "city": "San Francisco", "state": "CA", "zip": "94102", "country": "United States", "country_code": "us", "type": "WORK" } ], "birthday": "1990-01-15", "emails": [ { "email": "john.doe@example.com", "type": "WORK" } ], "name": { "formatted_name": "John Doe", "first_name": "John", "last_name": "Doe", "middle_name": "Michael", "suffix": "Jr.", "prefix": "Mr." }, "org": { "company": "Example Corp", "department": "Engineering", "title": "Senior Developer" }, "phones": [ { "phone": "+1234567890", "type": "WORK", "wa_id": "1234567890" } ], "urls": [ { "url": "https://example.com", "type": "WORK" } ] } } ``` ### Response #### Success Response (200) - **messaging_product** (string) - The messaging product used (e.g., "whatsapp"). - **contacts** (array) - Information about the contact(s) the message was sent to. - **input** (string) - The input phone number. - **wa_id** (string) - The WhatsApp ID of the contact. - **messages** (array) - Information about the sent message(s). - **id** (string) - The unique ID of the message. #### Response Example ```json { "messaging_product": "whatsapp", "contacts": [{ "input": "+1234567890", "wa_id": "1234567890" }], "messages": [{ "id": "wamid.HBgNMTIzNDU2Nzg5MAA=" }] } ``` ``` -------------------------------- ### Send Image Message by URL using cURL Source: https://context7.com/ramborau/botpe-mcp-2/llms.txt Sends an image message to WhatsApp users using a publicly accessible image URL via cURL. This command requires the recipient's phone number, image URL, API URL, version, business phone number ID, and an API key. It makes a POST request to the BotPe MCP API. ```bash curl -X POST "https://api.botpe.com/v1/123456789/messages" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_KEY" \ -d '{ "messaging_product": "whatsapp", "recipient_type": "individual", "to": "+1234567890", "type": "image", "image": { "link": "https://example.com/image.jpg" } }' ``` -------------------------------- ### Send Interactive Button Message with JavaScript Source: https://context7.com/ramborau/botpe-mcp-2/llms.txt Sends messages with interactive reply buttons for user selection using the send_reply_button tool. It requires recipient phone number, button text, and a list of buttons with IDs and titles. The function handles API requests and error responses. ```javascript const executeFunction = async ({ recipientPhoneNumber, buttonText, buttons }) => { const baseUrl = ''; const version = ''; const businessPhoneNumberId = ''; const token = process.env.BOTPE_MCP_API_KEY; try { const url = `${baseUrl}/${version}/${businessPhoneNumberId}/messages`; const messagePayload = { messaging_product: "whatsapp", recipient_type: "individual", to: recipientPhoneNumber, type: "interactive", interactive: { type: "button", body: { text: buttonText }, action: { buttons: buttons.map(button => ({ type: "reply", reply: { id: button.id, title: button.title } })) } } }; const response = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${token}` }, body: JSON.stringify(messagePayload) }); if (!response.ok) { const errorData = await response.json(); throw new Error(JSON.stringify(errorData)); } return await response.json(); } catch (error) { return { error: `An error occurred while sending the message: ${error.message}` }; } }; // Example usage via MCP client const result = await callTool('send_reply_button', { recipientPhoneNumber: '+1234567890', buttonText: 'Would you like to schedule an appointment?', buttons: [ { id: 'yes_schedule', title: 'Yes, Schedule' }, { id: 'no_thanks', title: 'No Thanks' }, { id: 'more_info', title: 'More Info' } ] }); // Expected response: // { // "messaging_product": "whatsapp", // "contacts": [{ "input": "+1234567890", "wa_id": "1234567890" }], // "messages": [{ "id": "wamid.HBgNMTIzNDU2Nzg5MAA=" }] // } ``` -------------------------------- ### Send Interactive List Message using JavaScript Source: https://context7.com/ramborau/botpe-mcp-2/llms.txt This tool sends interactive list messages that allow users to select from multiple options organized into sections. It requires recipient details, header, body, footer text, button text, and section data. The function constructs a POST request to the BotPe MCP API. ```javascript // Tool: send_list_message // File: tools/botpe-mcp/api-documentation/send-list-message.js const executeFunction = async ({ recipientPhoneNumber, headerText, bodyText, footerText, buttonText, sections }) => { const baseUrl = ''; const version = ''; const businessPhoneNumberId = ''; const token = process.env.BOTPE_MCP_API_KEY; const messageData = { messaging_product: "whatsapp", recipient_type: "individual", to: recipientPhoneNumber, type: "interactive", interactive: { type: "list", header: { type: "text", text: headerText }, body: { text: bodyText }, footer: { text: footerText }, action: { button: buttonText, sections: sections } } }; try { const response = await fetch(`${baseUrl}/${version}/${businessPhoneNumberId}/messages`, { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${token}` }, body: JSON.stringify(messageData) }); if (!response.ok) { const errorData = await response.json(); throw new Error(JSON.stringify(errorData)); } return await response.json(); } catch (error) { return { error: `An error occurred while sending the list message: ${error.message}` }; } }; // Example usage via MCP client const result = await callTool('send_list_message', { recipientPhoneNumber: '+1234567890', headerText: 'Select a Service', bodyText: 'Choose from our available services', footerText: 'Powered by BotPe', buttonText: 'View Options', sections: [ { title: 'Technical Support', rows: [ { id: 'tech_1', title: 'Setup Assistance', description: 'Help with initial setup and configuration' }, { id: 'tech_2', title: 'Troubleshooting', description: 'Resolve technical issues' } ] }, { title: 'Billing', rows: [ { id: 'bill_1', title: 'View Invoice', description: 'Check your current invoice' }, { id: 'bill_2', title: 'Payment Options', description: 'Update payment methods' } ] } ] }); // Expected response: // { // "messaging_product": "whatsapp", // "contacts": [{ "input": "+1234567890", "wa_id": "1234567890" }], // "messages": [{ "id": "wamid.HBgNMTIzNDU2Nzg5MAA=" }] // } ``` -------------------------------- ### Send Text Message using cURL Source: https://context7.com/ramborau/botpe-mcp-2/llms.txt Sends a simple text message to WhatsApp users using cURL. This command requires the recipient's phone number, message content, API URL, version, business phone number ID, and an API key. It makes a POST request to the BotPe MCP API. ```bash curl -X POST "https://api.botpe.com/v1/123456789/messages" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_KEY" \ -d '{ "messaging_product": "whatsapp", "recipient_type": "individual", "to": "+1234567890", "type": "text", "text": { "preview_url": false, "body": "Hello from BotPe!" } }' ``` -------------------------------- ### Send Image Message by URL using JavaScript Source: https://context7.com/ramborau/botpe-mcp-2/llms.txt Sends an image message to WhatsApp users using a publicly accessible image URL. This function requires the recipient's phone number and the image URL. It uses the BotPe MCP API and requires an API key for authorization. The response includes message status and ID. ```javascript const executeFunction = async ({ recipientPhoneNumber, imageUrl }) => { const baseUrl = ''; const version = ''; const businessPhoneNumberId = ''; const token = process.env.BOTPE_MCP_API_KEY; try { const url = `${baseUrl}/${version}/${businessPhoneNumberId}/messages`; const response = await fetch(url, { method: 'POST', headers: { 'Authorization': `Bearer ${token}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ messaging_product: "whatsapp", recipient_type: "individual", to: recipientPhoneNumber, type: "image", image: { link: imageUrl } }) }); if (!response.ok) { const errorData = await response.json(); throw new Error(JSON.stringify(errorData)); } return await response.json(); } catch (error) { return { error: `An error occurred while sending the image message: ${error.message}` }; } }; // Example usage via MCP client const result = await callTool('send_image_message', { recipientPhoneNumber: '+1234567890', imageUrl: 'https://example.com/image.jpg' }); // Expected response: // { // "messaging_product": "whatsapp", // "contacts": [{ "input": "+1234567890", "wa_id": "1234567890" }], // "messages": [{ "id": "wamid.HBgNMTIzNDU2Nzg5MAA=" }] // } ``` -------------------------------- ### Send Location Message using JavaScript Source: https://context7.com/ramborau/botpe-mcp-2/llms.txt This tool sends location coordinates along with name and address details to a recipient. It requires recipient phone number, location coordinates, and optionally name and address. The tool makes a POST request to the BotPe MCP API. ```javascript // Tool: send_location_message // File: tools/botpe-mcp/api-documentation/send-location-message.js const executeFunction = async ({ RecipientPhoneNumber, LocationLatitude, LocationLongitude, LocationName, LocationAddress }) => { const baseUrl = ''; const version = ''; const businessPhoneNumberId = ''; const token = process.env.BOTPE_MCP_API_KEY; try { const url = `${baseUrl}/${version}/${businessPhoneNumberId}/messages`; const response = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${token}` }, body: JSON.stringify({ messaging_product: "whatsapp", recipient_type: "individual", to: RecipientPhoneNumber, type: "location", location: { latitude: LocationLatitude, longitude: LocationLongitude, name: LocationName, address: LocationAddress } }) }); if (!response.ok) { const errorData = await response.json(); throw new Error(JSON.stringify(errorData)); } return await response.json(); } catch (error) { return { error: `An error occurred while sending the location message: ${error.message}` }; } }; // Example usage via MCP client const result = await callTool('send_location_message', { RecipientPhoneNumber: '+1234567890', LocationLatitude: 37.7749, LocationLongitude: -122.4194, LocationName: 'San Francisco City Hall', LocationAddress: '1 Dr Carlton B Goodlett Pl, San Francisco, CA 94102' }); // Expected response: // { // "messaging_product": "whatsapp", // "contacts": [{ "input": "+1234567890", "wa_id": "1234567890" }], // "messages": [{ "id": "wamid.HBgNMTIzNDU2Nzg5MAA=" }] // } ``` -------------------------------- ### Send Contact Message with JavaScript Source: https://context7.com/ramborau/botpe-mcp-2/llms.txt Sends contact information with full vCard details including name, phone numbers, emails, addresses, and organization using the send_contact_message tool. It requires the recipient's phone number and detailed contact object. The function handles API requests and error responses. ```javascript const executeFunction = async ({ RecipientPhoneNumber, contact }) => { const baseUrl = ''; const version = ''; const businessPhoneNumberId = ''; const token = process.env.BOTPE_MCP_API_KEY; try { const url = `${baseUrl}/${version}/${businessPhoneNumberId}/messages`; const response = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${token}` }, body: JSON.stringify({ messaging_product: "whatsapp", to: RecipientPhoneNumber, type: "contacts", contacts: [contact] }) }); if (!response.ok) { const errorData = await response.json(); throw new Error(JSON.stringify(errorData)); } return await response.json(); } catch (error) { return { error: `An error occurred while sending the contact message: ${error.message}` }; } }; // Example usage via MCP client const result = await callTool('send_contact_message', { RecipientPhoneNumber: '+1234567890', contact: { addresses: [ { street: '123 Main St', city: 'San Francisco', state: 'CA', zip: '94102', country: 'United States', country_code: 'us', type: 'WORK' } ], birthday: '1990-01-15', emails: [ { email: 'john.doe@example.com', type: 'WORK' } ], name: { formatted_name: 'John Doe', first_name: 'John', last_name: 'Doe', middle_name: 'Michael', suffix: 'Jr.', prefix: 'Mr.' }, org: { company: 'Example Corp', department: 'Engineering', title: 'Senior Developer' }, phones: [ { phone: '+1234567890', type: 'WORK', wa_id: '1234567890' } ], urls: [ { url: 'https://example.com', type: 'WORK' } ] } }); // Expected response: // { // "messaging_product": "whatsapp", // "contacts": [{ "input": "+1234567890", "wa_id": "1234567890" }], // "messages": [{ "id": "wamid.HBgNMTIzNDU2Nzg5MAA=" }] // } ``` -------------------------------- ### Send Text Message using JavaScript Source: https://context7.com/ramborau/botpe-mcp-2/llms.txt Sends a simple text message to WhatsApp users. This function requires recipient phone number and message content. It uses the BotPe MCP API and requires an API key for authorization. The response includes message status and ID. ```javascript const executeFunction = async ({ recipientPhoneNumber, messageContent }) => { const baseUrl = ''; const version = ''; const businessPhoneNumberId = ''; const token = process.env.BOTPE_MCP_API_KEY; try { const url = `${baseUrl}/${version}/${businessPhoneNumberId}/messages`; const response = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${token}` }, body: JSON.stringify({ messaging_product: "whatsapp", recipient_type: "individual", to: recipientPhoneNumber, type: "text", text: { preview_url: false, body: messageContent } }) }); if (!response.ok) { const errorData = await response.json(); throw new Error(JSON.stringify(errorData)); } return await response.json(); } catch (error) { return { error: `An error occurred while sending the text message: ${error.message}` }; } }; // Example usage via MCP client const result = await callTool('send_text_message', { recipientPhoneNumber: '+1234567890', messageContent: 'Hello from BotPe MCP Server!' }); // Expected response: // { // "messaging_product": "whatsapp", // "contacts": [{ "input": "+1234567890", "wa_id": "1234567890" }], // "messages": [{ "id": "wamid.HBgNMTIzNDU2Nzg5MAA=" }] // } ``` -------------------------------- ### Send Image Message by URL Source: https://context7.com/ramborau/botpe-mcp-2/llms.txt This endpoint allows you to send image messages to WhatsApp users using publicly accessible image URLs. It requires the recipient's phone number and the image URL. ```APIDOC ## POST /v1/{businessPhoneNumberId}/messages ### Description Send image messages using publicly accessible image URLs. ### Method POST ### Endpoint `/v1///messages` ### Parameters #### Path Parameters - **businessPhoneNumberId** (string) - Required - The phone number ID of the business. #### Query Parameters None #### Request Body - **messaging_product** (string) - Required - Should be "whatsapp". - **recipient_type** (string) - Required - Should be "individual". - **to** (string) - Required - The recipient's phone number (e.g., "+1234567890"). - **type** (string) - Required - Should be "image". - **image** (object) - Required - Contains image message details. - **link** (string) - Required - The publicly accessible URL of the image. ### Request Example ```json { "messaging_product": "whatsapp", "recipient_type": "individual", "to": "+1234567890", "type": "image", "image": { "link": "https://example.com/image.jpg" } } ``` ### Response #### Success Response (200) - **messaging_product** (string) - The messaging product used. - **contacts** (array) - Information about the recipients. - **input** (string) - The input phone number. - **wa_id** (string) - The WhatsApp ID of the recipient. - **messages** (array) - Information about the sent messages. - **id** (string) - The message ID. #### Response Example ```json { "messaging_product": "whatsapp", "contacts": [ { "input": "+1234567890", "wa_id": "1234567890" } ], "messages": [ { "id": "wamid.HBgNMTIzNDU2Nzg5MAA=" } ] } ``` ``` -------------------------------- ### Send Text Message Source: https://context7.com/ramborau/botpe-mcp-2/llms.txt This endpoint allows you to send simple text messages to WhatsApp users. It requires the recipient's phone number and the message content. ```APIDOC ## POST /v1/{businessPhoneNumberId}/messages ### Description Send simple text messages to WhatsApp users. ### Method POST ### Endpoint `/v1///messages` ### Parameters #### Path Parameters - **businessPhoneNumberId** (string) - Required - The phone number ID of the business. #### Query Parameters None #### Request Body - **messaging_product** (string) - Required - Should be "whatsapp". - **recipient_type** (string) - Required - Should be "individual". - **to** (string) - Required - The recipient's phone number (e.g., "+1234567890"). - **type** (string) - Required - Should be "text". - **text** (object) - Required - Contains text message details. - **preview_url** (boolean) - Optional - Whether to preview URLs in the message. - **body** (string) - Required - The content of the text message. ### Request Example ```json { "messaging_product": "whatsapp", "recipient_type": "individual", "to": "+1234567890", "type": "text", "text": { "preview_url": false, "body": "Hello from BotPe MCP Server!" } } ``` ### Response #### Success Response (200) - **messaging_product** (string) - The messaging product used. - **contacts** (array) - Information about the recipients. - **input** (string) - The input phone number. - **wa_id** (string) - The WhatsApp ID of the recipient. - **messages** (array) - Information about the sent messages. - **id** (string) - The message ID. #### Response Example ```json { "messaging_product": "whatsapp", "contacts": [ { "input": "+1234567890", "wa_id": "1234567890" } ], "messages": [ { "id": "wamid.HBgNMTIzNDU2Nzg5MAA=" } ] } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.