Email Digest Generator
Automatically summarize newsletters, industry news, and team updates into concise digests.
This workflow aggregates emails, extracts key points, and generates personalized summaries.
Implementation
1import { relay } from "@relayplane/workflows";23const result = await relay4 .workflow("email-digest")56 // Step 1: Extract key information from each email7 .step("extract-emails")8 .with("openai:gpt-4o")9 .prompt(`Extract key information from these emails:1011{{emailBatch}}1213For each email, extract:14- Sender and subject15- Main topic/theme16- Key points (max 3 per email)17- Action items or deadlines18- Priority level (high/medium/low)1920Skip promotional content and automated notifications.21Return as JSON array.`)2223 // Step 2: Categorize by topic24 .step("categorize")25 .with("anthropic:claude-3.5-sonnet")26 .depends("extract-emails")27 .prompt(`Categorize these emails by topic:2829{{extract-emails.output}}3031Categories:32- Industry News33- Product Updates34- Team Announcements35- Customer Feedback36- Technical Discussions37- Administrative3839Group related emails together.40Return categorized structure.`)4142 // Step 3: Generate summary43 .step("generate-summary")44 .with("anthropic:claude-3.5-sonnet")45 .depends("categorize")46 .prompt(`Create a concise email digest:4748{{categorize.output}}4950Format:51# Daily Digest - {{date}}5253## 🔥 Requires Action54- Items with deadlines or requests5556## 📰 Industry News57- Key trends and announcements5859## 💼 Team Updates60- Internal announcements6162## 💡 Worth Reading63- Interesting insights6465Keep each section to 3-5 bullet points.66Total length: under 300 words.67Include links to original emails.`)6869 .run({70 emailBatch: emails.map(e => ({71 from: e.from,72 subject: e.subject,73 body: e.textContent.slice(0, 1000), // First 1000 chars74 receivedAt: e.date,75 })),76 date: new Date().toLocaleDateString(),77 });7879// Send digest80await sendEmail({81 to: user.email,82 subject: `Your Daily Digest - ${new Date().toLocaleDateString()}`,83 html: markdownToHTML(result.steps["generate-summary"].output),84});Gmail Integration
1import { google } from 'googleapis';2import { relay } from "@relayplane/workflows";34async function dailyDigest() {5 const gmail = google.gmail({ version: 'v1', auth: oAuth2Client });67 // Fetch unread emails from last 24 hours8 const response = await gmail.users.messages.list({9 userId: 'me',10 q: 'is:unread newer_than:1d',11 maxResults: 50,12 });1314 const emails = [];15 for (const msg of response.data.messages || []) {16 const full = await gmail.users.messages.get({17 userId: 'me',18 id: msg.id,19 format: 'full',20 });2122 emails.push({23 from: getHeader(full, 'From'),24 subject: getHeader(full, 'Subject'),25 body: extractTextBody(full),26 date: getHeader(full, 'Date'),27 });28 }2930 // Generate digest31 const digest = await relay32 .workflow("email-digest")33 .run({34 emailBatch: emails,35 date: new Date().toLocaleDateString(),36 });3738 return digest.steps["generate-summary"].output;39}4041// Schedule for 8am daily42cron.schedule('0 8 * * *', dailyDigest);Advanced Filtering
1// Custom filters2const result = await relay3 .workflow("email-digest")4 .step("extract-emails")5 .with("openai:gpt-4o")6 .prompt(`Extract key info from emails:78{{emailBatch}}910FILTERS:11- Exclude: automated CI/CD notifications, marketing emails12- Prioritize: emails from leadership, customer escalations13- Flag: any mentions of "urgent", "deadline", "asap"1415For each relevant email, extract key points.`)16 .step("generate-summary")17 .with("anthropic:claude-3.5-sonnet")18 .depends("extract-emails")19 .run({ emailBatch: emails });Sample Output
# Daily Digest - Nov 18, 2025 ## 🔥 Requires Action - **Sarah (Product)**: Review Q4 roadmap by EOD Friday - **Customer Success**: Enterprise client requesting demo of new features - **IT Security**: Complete security training by Nov 25 ## 📰 Industry News - OpenAI releases GPT-5 with extended context window (128k tokens) - New EU AI regulation impacts enterprise deployments - Anthropic announces Claude 4 with improved reasoning ## 💼 Team Updates - Engineering shipped v3.2 with performance improvements - Sales hit 125% of monthly target - New hire starting Monday: Alex Chen (DevOps) ## 💡 Worth Reading - Thoughtful piece on AI safety from DeepMind - Case study: How Stripe uses AI for fraud detection
Customization
- Add sentiment analysis to flag urgent/negative emails
- Integration with Slack for channel digests
- Personalized summaries based on user role
- Weekly rollup instead of daily