send_transactional_email
Send automated emails to recipients using Sitecore Send's transactional service. This tool delivers personalized messages with custom subjects and HTML content for notifications, confirmations, or alerts.
Instructions
Send an email using transactional email service
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| to | Yes | Email of the recipient | |
| subject | Yes | Subject of the email | |
| body | Yes | HTML body of the email |
Implementation Reference
- src/tools/api.ts:181-214 (handler)The main handler function that sends the transactional email to the specified recipient using the SendClient library. It constructs the email payload with subject, HTML body, and recipient, sends it via the transactional API, and returns success or error message.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 for input validation: requires 'to' (email), 'subject' (string), and 'body' (string) parameters.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:168-216 (registration)Registers the 'send_transactional_email' tool on the FastMCP server conditionally if a transactional campaign ID is provided in the config. Includes schema, annotations, and handler.if (transactoinalConfog.campaignId) { server.addTool({ 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}` } ] } } } }); }
- src/tools/index.ts:8-8 (registration)Invokes addApiTools within the main addTools function, which registers the send_transactional_email tool among API tools.addApiTools(server, config.api, config.transactionalEmails);