create_attachment_action
Create a new attachment action in Webex by specifying action type, message ID, and associated inputs like name, URL, email, and telephone number for enhanced messaging functionality.
Instructions
Create a new attachment action in Webex.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| inputs | Yes | ||
| messageId | Yes | The ID of the message to which the attachment is related. | |
| type | Yes | The type of the action (e.g., "submit"). |
Implementation Reference
- The main handler function `executeFunction` that implements the core logic: constructs Webex API URL and headers, sends POST request with type, messageId, and inputs, handles response or error.const executeFunction = async ({ type, messageId, inputs }) => { try { // Construct the URL for the request const url = getWebexUrl('/attachment/actions'); // Set up headers for the request const headers = getWebexJsonHeaders(); // Create the body of the request const body = JSON.stringify({ type, messageId, inputs }); // Perform the fetch request const response = await fetch(url, { method: 'POST', headers, body }); // 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 creating attachment action:', error); return { error: 'An error occurred while creating the attachment action.' }; } };
- The JSON Schema defining the tool's input parameters: object with 'type' (string), 'messageId' (string, required), and 'inputs' object (required) containing 'Name', 'Url', 'Email', 'Tel' (all strings, required).parameters: { type: 'object', properties: { type: { type: 'string', description: 'The type of the action (e.g., "submit").' }, messageId: { type: 'string', description: 'The ID of the message to which the attachment is related.' }, inputs: { type: 'object', properties: { Name: { type: 'string', description: 'The name associated with the action.' }, Url: { type: 'string', description: 'The URL associated with the action.' }, Email: { type: 'string', description: 'The email associated with the action.' }, Tel: { type: 'string', description: 'The telephone number associated with the action.' } }, required: ['Name', 'Url', 'Email', 'Tel'] } }, required: ['messageId', 'inputs'] }
- The `apiTool` object that registers the tool, linking the handler `executeFunction` to the schema under the name 'create_attachment_action', and exports it for loading by the MCP tools system.const apiTool = { function: executeFunction, definition: { type: 'function', function: { name: 'create_attachment_action', description: 'Create a new attachment action in Webex.', parameters: { type: 'object', properties: { type: { type: 'string', description: 'The type of the action (e.g., "submit").' }, messageId: { type: 'string', description: 'The ID of the message to which the attachment is related.' }, inputs: { type: 'object', properties: { Name: { type: 'string', description: 'The name associated with the action.' }, Url: { type: 'string', description: 'The URL associated with the action.' }, Email: { type: 'string', description: 'The email associated with the action.' }, Tel: { type: 'string', description: 'The telephone number associated with the action.' } }, required: ['Name', 'Url', 'Email', 'Tel'] } }, required: ['messageId', 'inputs'] } } } }; export { apiTool };