Email triage means sorting incoming email into the right categories and routing them to the appropriate handler. AgentMailr does the categorization automatically. You write the routing logic.
Available Categories
- verification: OTP codes, email confirmation links, account activation
- security: Password resets, suspicious login alerts, 2FA backup codes
- transactional: Receipts, invoices, order confirmations, shipping notifications
- notification: Mentions, comments, assignments, deployment alerts
- newsletter: Subscriptions, weekly digests, marketing emails
- conversation: Replies and direct messages
- calendar: Meeting invitations, RSVPs
Routing Example
const handlers = {
verification: handleVerification,
security: handleSecurityAlert,
transactional: logTransaction,
conversation: forwardToAgent,
newsletter: archive,
};
async function triageEmail(email) {
const category = email.parsed.category;
const handler = handlers[category] || defaultHandler;
await handler(email);
}
async function handleVerification(email) {
const otp = email.parsed.otp_codes[0];
const link = email.parsed.verification_links[0];
if (otp) await submitOtp(otp);
else if (link) await clickVerificationLink(link);
}
async function handleSecurityAlert(email) {
// Notify admin immediately for security emails
await notifyAdmin(email.parsed.summary);
}
async function archive(email) {
// Just mark as read and move on
console.log("Newsletter archived:", email.subject);
}
Confidence Scores
Each email also includes a parsed.confidence score from 0 to 1. High confidence (above 0.8) means the category is almost certainly correct. Low confidence (below 0.5) might warrant a default handler or human review.
Action Required Flag
The parsed.action_required boolean is true if the email contains an OTP code, verification link, or magic link. Use this to prioritize urgent emails over newsletters.