buddypress_create_message
Send private messages to multiple users on a BuddyPress community site by specifying recipients, subject, and message content.
Instructions
Create a new message
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| message | Yes | Message content | |
| recipients | Yes | Array of recipient user IDs | |
| sender_id | No | Sender user ID (default: current user) | |
| subject | Yes | Message subject |
Implementation Reference
- src/index.ts:699-701 (handler)Handler function that executes the buddypress_create_message tool by making a POST request to the BuddyPress /messages endpoint using the provided arguments.else if (name === 'buddypress_create_message') { result = await buddypressRequest('/messages', 'POST', args); }
- src/index.ts:431-440 (schema)Input schema definition for the buddypress_create_message tool, specifying parameters like recipients, subject, and message.inputSchema: { type: 'object', properties: { sender_id: { type: 'number', description: 'Sender user ID (default: current user)' }, recipients: { type: 'array', items: { type: 'number' }, description: 'Array of recipient user IDs', required: true }, subject: { type: 'string', description: 'Message subject', required: true }, message: { type: 'string', description: 'Message content', required: true }, }, required: ['recipients', 'subject', 'message'], },
- src/index.ts:428-441 (registration)Registration of the buddypress_create_message tool in the tools array, including name, description, and input schema.{ name: 'buddypress_create_message', description: 'Create a new message', inputSchema: { type: 'object', properties: { sender_id: { type: 'number', description: 'Sender user ID (default: current user)' }, recipients: { type: 'array', items: { type: 'number' }, description: 'Array of recipient user IDs', required: true }, subject: { type: 'string', description: 'Message subject', required: true }, message: { type: 'string', description: 'Message content', required: true }, }, required: ['recipients', 'subject', 'message'], }, },
- src/index.ts:18-46 (helper)Shared helper utility that makes authenticated HTTP requests to the BuddyPress REST API, used by all tools including buddypress_create_message.async function buddypressRequest( endpoint: string, method: string = 'GET', body?: any ): Promise<any> { const url = `${BUDDYPRESS_URL}/wp-json/buddypress/v2${endpoint}`; const auth = Buffer.from(`${BUDDYPRESS_USERNAME}:${BUDDYPRESS_PASSWORD}`).toString('base64'); const options: any = { method, headers: { 'Authorization': `Basic ${auth}`, 'Content-Type': 'application/json', }, }; if (body && method !== 'GET') { options.body = JSON.stringify(body); } const response = await fetch(url, options); if (!response.ok) { const errorText = await response.text(); throw new Error(`BuddyPress API Error (${response.status}): ${errorText}`); } return await response.json(); }