run_ai_action
Execute AI prompts on specific Carbon Voice messages to generate responses, analyze content, or perform automated actions based on message IDs.
Instructions
Run an AI Action (Prompt) for a message. You can run an AI Action for a message by its ID or a list of message IDs.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| prompt_id | Yes | ||
| message_ids | Yes | ||
| channel_id | No | ||
| workspace_id | No | ||
| language | No | The language of the response. Defaults to original message. |
Implementation Reference
- src/server.ts:872-884 (handler)The handler function that implements the core logic of the 'run_ai_action' tool. It invokes the simplified API's aIResponseControllerCreateResponse method with the input arguments and authentication header, formats the response, and handles errors.async (args: CreateAIResponse, { authInfo }): Promise<McpToolResponse> => { try { return formatToMCPToolResponse( await simplifiedApi.aIResponseControllerCreateResponse( args, setCarbonVoiceAuthHeader(authInfo?.token), ), ); } catch (error) { logger.error('Error running ai action:', { error }); return formatToMCPToolResponse(error); } },
- src/server.ts:861-885 (registration)Registers the 'run_ai_action' tool on the MCP server, specifying its name, description, input schema, annotations, and handler function.server.registerTool( 'run_ai_action', { description: 'Run an AI Action (Prompt) for a message. You can run an AI Action for a message by its ID or a list of message IDs.', inputSchema: aIResponseControllerCreateResponseBody.shape, annotations: { readOnlyHint: false, destructiveHint: false, }, }, async (args: CreateAIResponse, { authInfo }): Promise<McpToolResponse> => { try { return formatToMCPToolResponse( await simplifiedApi.aIResponseControllerCreateResponse( args, setCarbonVoiceAuthHeader(authInfo?.token), ), ); } catch (error) { logger.error('Error running ai action:', { error }); return formatToMCPToolResponse(error); } }, );
- Zod schema definition for the input body of the aIResponseControllerCreateResponse API call, used as inputSchema for the tool.export const aIResponseControllerCreateResponseBody = zod.object({ "prompt_id": zod.string(), "message_ids": zod.array(zod.string()), "channel_id": zod.string().optional(), "workspace_id": zod.string().optional(), "language": zod.string().optional().describe('The language of the response. Defaults to original message.') })
- TypeScript interface defining the shape of the input arguments for the 'run_ai_action' handler.export interface CreateAIResponse { prompt_id: string; message_ids: string[]; channel_id?: string; workspace_id?: string; /** The language of the response. Defaults to original message. */ language?: string; }