edit_message
Update text or markdown in a Webex message by specifying the message ID, room ID, and new content. Enables quick edits to enhance clarity or correct errors.
Instructions
Edit a message in Webex.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| markdown | No | The new markdown for the message (optional). | |
| messageId | Yes | The unique identifier for the message to edit. | |
| roomId | Yes | The ID of the room where the message is located. | |
| text | Yes | The new text for the message. |
Implementation Reference
- The main handler function that executes the edit_message tool logic. It sends a PUT request to the Webex API to update the message with new text and optional markdown.const executeFunction = async ({ messageId, roomId, text, markdown }) => { try { // Construct the URL for the PUT request const url = getWebexUrl(`/messages/${encodeURIComponent(messageId)}`); // Prepare the request body const body = JSON.stringify({ roomId, text, ...(markdown && { markdown }) // Include markdown only if provided }); // Set up headers for the request const headers = getWebexJsonHeaders(); // 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 editing the message:', error); return { error: error.message || 'An error occurred while editing the message.', details: error.stack }; } };
- The input schema and tool name definition for the edit_message tool, including parameters and required fields.function: { name: 'edit_message', description: 'Edit a message in Webex.', parameters: { type: 'object', properties: { messageId: { type: 'string', description: 'The unique identifier for the message to edit.' }, roomId: { type: 'string', description: 'The ID of the room where the message is located.' }, text: { type: 'string', description: 'The new text for the message.' }, markdown: { type: 'string', description: 'The new markdown for the message (optional).' } }, required: ['messageId', 'text'] } }
- The apiTool object that encapsulates the handler and schema, exported from the tool file for registration.const apiTool = { function: executeFunction, definition: { type: 'function', function: { name: 'edit_message', description: 'Edit a message in Webex.', parameters: { type: 'object', properties: { messageId: { type: 'string', description: 'The unique identifier for the message to edit.' }, roomId: { type: 'string', description: 'The ID of the room where the message is located.' }, text: { type: 'string', description: 'The new text for the message.' }, markdown: { type: 'string', description: 'The new markdown for the message (optional).' } }, required: ['messageId', 'text'] } } } };
- tools/paths.js:33-33 (registration)The edit_message tool file is registered by being listed in the toolPaths array used for dynamic discovery.'webex-public-workspace/webex-messaging/edit-a-message.js',
- lib/tools.js:7-16 (registration)The discoverTools function that dynamically loads and registers all tools, including edit_message, by importing their apiTool objects.export async function discoverTools() { const toolPromises = toolPaths.map(async (file) => { const module = await import(`../tools/${file}`); return { ...module.apiTool, path: file, }; }); return Promise.all(toolPromises); }