Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Smart Category Digest Feature #274

Open
11 tasks
elie222 opened this issue Dec 19, 2024 · 0 comments
Open
11 tasks

Add Smart Category Digest Feature #274

elie222 opened this issue Dec 19, 2024 · 0 comments

Comments

@elie222
Copy link
Owner

elie222 commented Dec 19, 2024

Create a digest view that summarizes all emails within a Smart Category for a given time period.

Background

We currently have Smart Categories that automatically categorize emails from certain senders (e.g., Newsletters, Updates, etc.).

We'd like to add a summary (digest) of all emails in a category in a certain time period.

For example, a summary of all newsletters I received in the last 24 hours. In the future, this digest could be sent to users on a recurring basis.

Tasks

UI Implementation

  • Add "View Digest" button to Smart Category sections
  • Create digest view component to display:
    • Category name
    • Time period
    • Overall summary
    • Individual email summaries
  • Add loading states
  • Handle empty states (no emails in period)

Backend Implementation

  • Create digest generation service
  • Implement email fetching for time period
  • Add AI summary generation for given emails
  • Optional: Save to db / Add caching to prevent regenerating same digests

Testing

  • Add tests for digest generation
  • Test different time periods
  • Test with various email formats

Technical Notes

  • Use existing Smart Category infrastructure
  • Consider handling of very large email volumes

Future Enhancement (Separate Issue)

  • Scheduled digest delivery via email
  • Customizable delivery schedule
  • Email template design for digest

Done when

  • Users can view digest for any Smart Category (for the last day)
  • Digest shows clear summary of category emails

Example Implementation (AI generated)

// types.ts
interface DigestEmail {
  sender: string;
  subject: string;
  timestamp: Date;
  summary: string; // AI-generated summary
}

interface CategoryDigest {
  category: string; // e.g. "Newsletters" 
  timespan: string; // e.g. "Last 24 hours"
  emails: DigestEmail[];
  overallSummary: string; // AI summary of all emails combined
}

// digest-service.ts
async function generateCategoryDigest(
  category: string,
  timeRange: { start: Date; end: Date }
): Promise<CategoryDigest> {
  // 1. Get all emails in category within time range
  const emails = await emailProvider.listMessages({
    category,
    after: timeRange.start,
    before: timeRange.end
  });

  // 2. Generate summaries for each email
  const digestEmails: DigestEmail[] = await Promise.all(
    emails.map(async email => ({
      sender: email.from,
      subject: email.subject,
      timestamp: email.date,
      summary: await generateEmailSummary(email.content)
    }))
  );

  // 3. Generate overall category summary
  const overallSummary = await generateOverallSummary(digestEmails);

  return {
    category,
    timespan: "Last 24 hours",
    emails: digestEmails,
    overallSummary
  };
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant