list_direct_messages
Retrieve all messages from a 1:1 room in Cisco Webex by specifying a parent ID, person ID, or email. Enables efficient message tracking and management.
Instructions
List all messages in a 1:1 room.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| parentId | Yes | The parent ID to filter messages. | |
| personEmail | Yes | The person email to filter messages in a 1:1 room. | |
| personId | Yes | The person ID to filter messages in a 1:1 room. |
Implementation Reference
- The handler function that executes the tool logic: constructs Webex API URL for /messages/direct with parameters and fetches the list of direct messages.const executeFunction = async ({ parentId, personId, personEmail }) => { try { // Construct the URL with query parameters const url = new URL(getWebexUrl('/messages/direct')); url.searchParams.append('parentId', parentId); // Add either personId OR personEmail, not both if (personId) { url.searchParams.append('personId', personId); } else if (personEmail) { url.searchParams.append('personEmail', personEmail); } // Set up headers for the request const headers = getWebexHeaders(); // Perform the fetch request const response = await fetch(url.toString(), { method: 'GET', headers }); // 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 listing direct messages:', error); return { error: error.message || 'An error occurred while listing direct messages.', details: error.stack }; } };
- JSON Schema defining the input parameters for the tool: parentId (required filter), personId or personEmail (optional for 1:1 room).parameters: { type: 'object', properties: { parentId: { type: 'string', description: 'The parent ID to filter messages.' }, personId: { type: 'string', description: 'The person ID to filter messages in a 1:1 room.' }, personEmail: { type: 'string', description: 'The person email to filter messages in a 1:1 room.' } }, required: [] }
- Tool registration object 'apiTool' that binds the handler to the schema definition with name 'list_direct_messages' and exports it.const apiTool = { function: executeFunction, definition: { type: 'function', function: { name: 'list_direct_messages', description: 'List all messages in a 1:1 room.', parameters: { type: 'object', properties: { parentId: { type: 'string', description: 'The parent ID to filter messages.' }, personId: { type: 'string', description: 'The person ID to filter messages in a 1:1 room.' }, personEmail: { type: 'string', description: 'The person email to filter messages in a 1:1 room.' } }, required: [] } } } };
- tools/paths.js:28-28 (helper)The tool file path listed in toolPaths array, likely used for dynamic loading of Webex messaging tools.'webex-public-workspace/webex-messaging/list-direct-messages.js',