list_events
Retrieve and filter events within your organization using the Webex Messaging API. Specify parameters like resource type, actor ID, date range, and maximum results to customize the output.
Instructions
List events in your organization using the Webex Messaging API.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| actorId | Yes | The ID of the actor to filter events. | |
| from | Yes | The start date to filter events. | |
| max | No | The maximum number of events to return. | |
| resource | No | The resource type to filter events. | |
| to | Yes | The end date to filter events. | |
| type | No | The type of events to list. |
Implementation Reference
- Handler function that executes the list_events tool by constructing a Webex API request to /events with provided filters and returning the response data or error.const executeFunction = async ({ resource = 'messages', type = 'created', actorId, from, to, max = 100 }) => { try { // Construct the URL with query parameters const url = new URL(getWebexUrl('/events')); url.searchParams.append('resource', resource); url.searchParams.append('type', type); url.searchParams.append('actorId', actorId); url.searchParams.append('from', from); url.searchParams.append('to', to); url.searchParams.append('max', max.toString()); // 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(errorData); } // Parse and return the response data const data = await response.json(); return data; } catch (error) { console.error('Error listing events:', error); return { error: 'An error occurred while listing events.' }; } };
- Tool definition including name 'list_events', description, and JSON schema for input parameters with required fields actorId, from, to.const apiTool = { function: executeFunction, definition: { type: 'function', function: { name: 'list_events', description: 'List events in your organization using the Webex Messaging API.', parameters: { type: 'object', properties: { resource: { type: 'string', description: 'The resource type to filter events.' }, type: { type: 'string', description: 'The type of events to list.' }, actorId: { type: 'string', description: 'The ID of the actor to filter events.' }, from: { type: 'string', description: 'The start date to filter events.' }, to: { type: 'string', description: 'The end date to filter events.' }, max: { type: 'integer', description: 'The maximum number of events to return.' } }, required: ['actorId', 'from', 'to'] } } } };
- lib/tools.js:7-16 (registration)Dynamic registration of all tools, including list_events, by importing modules listed in toolPaths and spreading 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); }