extension-email
This skill enables sending service and transactional emails directly from the backend canister. It provides a streamlined interface for developers to easily integrate email sending capabilities, ensuring critical information like order confirmations, password resets, and notifications reaches users promptly. This enhances user experience and system reliability by automating essential communication workflows and reducing the complexity of external email service interactions.
npx skills add https://github.com/caffeinelabs/skills --skill extension-emailBefore / After Comparison
1 组Before this skill, developers had to manually integrate third-party email services, writing extensive code for API calls, error handling, and recipient management. This was time-consuming and prone to errors, delaying feature deployment.
This Skill provides a concise interface, allowing developers to send service emails with a single function call. This significantly simplifies the integration process, reduces development effort and potential errors, and accelerates feature deployment.
Email — Service/Transactional
Service/transactional email extension for Caffeine AI.
Overview
This skill adds support for sending service and transactional emails from the backend canister. Use sendServiceEmail for order confirmations, notifications, and similar one-off emails.
Backend
This component is for sending service/transactional emails.
There is the prefabricated module mo:caffeineai-email/emailClient.mo which cannot be modified.
- Use the sendServiceEmail function.
- Each recipient is sent an individual email
- It returns a SendResult which is #ok if the email is sent successfully otherwise #err(error) with the error text.
module {
public type SendResult = {
#ok;
#err : Text;
};
public func sendServiceEmail(
fromUsername : Text,
recipients : [Text],
subject : Text,
htmlBody : Text,
) : async SendResult;
};
Usage for sendServiceEmail:
import Runtime "mo:core/Runtime";
import EmailClient "mo:caffeineai-email/emailClient";
actor {
public func sendOrderConfirmationEmail(recipientEmailAddress : Text, username : Text, orderReference : Text) : async () {
let result = await EmailClient.sendServiceEmail(
"no-reply",
[recipientEmailAddress],
"Order " # orderReference # " confirmed",
"Hello " # username # ",\nYour order " # orderReference # " has been confirmed. Your items will ship tomorrow.",
);
switch (result) {
case (#ok) {};
case (#err(error)) {
Runtime.trap("Failed to send order confirmation email: " # error);
};
};
};
};
User Reviews (0)
Write a Review
No reviews yet
Statistics
User Rating
Rate this Skill