list_messages
Retrieve messages from a Webex room by room ID, filter by parent message, mentioned people, date, or message ID, and set a response limit.
Instructions
List messages in a Webex room.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| before | No | List messages sent before a specific date and time. | |
| beforeMessage | No | List messages sent before a specific message, by ID. | |
| max | No | Limit the maximum number of messages in the response. | |
| mentionedPeople | No | List messages with these people mentioned, by ID. | |
| parentId | No | The ID of the parent message to filter by. | |
| roomId | Yes | The ID of the room to list messages from. |
Implementation Reference
- The main handler function `executeFunction` that lists messages from a Webex room using the Webex API.const executeFunction = async ({ roomId, parentId, mentionedPeople, before, beforeMessage, max = 100 }) => { try { // Construct the URL with query parameters const url = new URL(getWebexUrl('/messages')); url.searchParams.append('roomId', roomId); if (parentId) url.searchParams.append('parentId', parentId); if (mentionedPeople) url.searchParams.append('mentionedPeople', mentionedPeople); if (before) url.searchParams.append('before', before); if (beforeMessage) url.searchParams.append('beforeMessage', beforeMessage); url.searchParams.append('max', max.toString()); // Get headers using centralized config 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 messages:', error); return { error: error.message || 'An error occurred while listing messages.', details: error.stack }; } };
- The `apiTool` configuration defining the tool schema, name, description, and input parameters for 'list_messages'.const apiTool = { function: executeFunction, definition: { type: 'function', function: { name: 'list_messages', description: 'List messages in a Webex room.', parameters: { type: 'object', properties: { roomId: { type: 'string', description: 'The ID of the room to list messages from.' }, parentId: { type: 'string', description: 'The ID of the parent message to filter by.' }, mentionedPeople: { type: 'string', description: 'List messages with these people mentioned, by ID.' }, before: { type: 'string', description: 'List messages sent before a specific date and time.' }, beforeMessage: { type: 'string', description: 'List messages sent before a specific message, by ID.' }, max: { type: 'integer', description: 'Limit the maximum number of messages in the response.' } }, required: ['roomId'] } } } };
- lib/tools.js:7-16 (registration)The `discoverTools` function that dynamically loads and registers the `apiTool` from list-messages.js and other tool files.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); }
- tools/paths.js:51-51 (registration)The path to list-messages.js is listed in the `toolPaths` array used by discoverTools for registration.'webex-public-workspace/webex-messaging/list-messages.js',