send_transactional_email
Send personalized transactional emails with recipient details, subject, and HTML body content using a Sitecore Send service for targeted communication.
Instructions
Send an email using transactional email service
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| body | Yes | HTML body of the email | |
| subject | Yes | Subject of the email | |
| to | Yes | Email of the recipient |
Implementation Reference
- src/tools/api.ts:181-214 (handler)Handler function that executes the tool logic: sends a transactional email using the SendClient's transactional.sendEmail method, handling success and error responses.execute: async ({ to, subject, body }) => { try { const result = await client.transactional.sendEmail({ Subject: subject, CampaignId: transactoinalConfog.campaignId!, Personalizations: [ { To: [ { Email: to, } ], } ], Content: [ { Value: body, Type: "text/html", }, ] }); return { content: [ { type: "text", text: `Email sent ${result.TotalAccepted > 0 ? "successfully" : "unsuccessfully"}` } ] } } catch (e) { return { content: [ { type: "text", text: `Error: ${(e as ApiResponseError).sendResponse?.Error}` } ] } } }
- src/tools/api.ts:172-176 (schema)Zod schema defining the input parameters for the tool: recipient email (to), subject, and HTML body.parameters: z.object({ to: z.string().email().describe("Email of the recipient"), subject: z.string().describe("Subject of the email"), body: z.string().describe("HTML body of the email"), }),
- src/tools/api.ts:170-215 (registration)Registers the 'send_transactional_email' tool with the FastMCP server inside the addApiTools function, conditional on campaignId being provided.name: "send_transactional_email", description: "Send an email using transactional email service", parameters: z.object({ to: z.string().email().describe("Email of the recipient"), subject: z.string().describe("Subject of the email"), body: z.string().describe("HTML body of the email"), }), annotations: { title: "Send an email using transactional email service", openWorldHint: true, }, execute: async ({ to, subject, body }) => { try { const result = await client.transactional.sendEmail({ Subject: subject, CampaignId: transactoinalConfog.campaignId!, Personalizations: [ { To: [ { Email: to, } ], } ], Content: [ { Value: body, Type: "text/html", }, ] }); return { content: [ { type: "text", text: `Email sent ${result.TotalAccepted > 0 ? "successfully" : "unsuccessfully"}` } ] } } catch (e) { return { content: [ { type: "text", text: `Error: ${(e as ApiResponseError).sendResponse?.Error}` } ] } } } });