Skip to main content

Email Prioritization & Inbox Operations

Intelligent inbox management powered by multi-agent vetted decisionmaking, sender history, and cross-channel context.

Overview

The Email Prioritization system scores and ranks emails based on urgency, importance, and historical behavior. It supports real-time inbox ranking, follow-up tracking, and snooze recommendations to help teams focus on the highest-impact messages.

Architecture

┌─────────────────────────────────────────────────────────────────┐
│ EMAIL PRIORITIZATION │
├─────────────────────────────────────────────────────────────────┤
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Tier 1 │ │ Tier 2 │ │ Tier 3 │ │
│ │ Rule-Based │───▶│ Lightweight│───▶│ Multi-Agent │ │
│ │ <200ms │ │ <500ms │ │ <5s │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ ┌──────────────────────────────────────────────────┐ │
│ │ Sender History Service │ │
│ │ - Reputation tracking │ │
│ │ - Response patterns │ │
│ │ - VIP/blocked management │ │
│ └──────────────────────────────────────────────────┘ │
│ │ │
│ ┌──────────────────────────────────────────────────┐ │
│ │ Cross-Channel Context Service │ │
│ │ - Slack activity signals │ │
│ │ - Calendar integration │ │
│ │ - Google Drive relevance │ │
│ └──────────────────────────────────────────────────┘ │
│ │ │
│ ┌──────────────────────────────────────────────────┐ │
│ │ Follow-Up Tracker + Snooze Recommender │ │
│ │ - Awaiting replies │ │
│ │ - Smart snooze suggestions │ │
│ └──────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────┘

Priority Levels

PriorityValueDescriptionExamples
CRITICAL5Requires immediate attentionVIP sender, urgent deadline
HIGH4Important, respond todayManager email, time-sensitive
MEDIUM3Standard priorityRegular work email
LOW2Can waitFYI emails, CC'd emails
DEFER1Read later or archiveNewsletters, marketing

3-Tier Scoring System

Tier 1: Rule-Based (< 200ms)

Fast pattern matching for high-confidence decisions:

  • VIP sender detection
  • Newsletter/marketing identification
  • Urgency keyword detection
  • Deadline pattern matching
  • Auto-archive sender matching

Tier 2: Lightweight Agent (< 500ms)

Single-agent analysis for ambiguous cases:

  • Content summarization
  • Context-aware scoring
  • Sender reputation integration

Tier 3: Multi-Agent Debate (< 5s)

Full vetted decisionmaking-based prioritization for complex decisions:

  • Multiple specialized agents
  • Sender reputation
  • Content urgency
  • Context relevance
  • Timeline and compliance perspectives

API Endpoints

All endpoints are served under /api/v1/email unless otherwise noted.

MethodEndpointDescription
POST/api/v1/email/prioritizeScore a single email
POST/api/v1/email/prioritize/batchScore multiple emails
POST/api/v1/email/rank-inboxRank a provided list
GET/api/v1/email/inboxFetch + rank inbox (Gmail)
POST/api/v1/email/feedbackRecord a user action
POST/api/v1/email/feedback/batchBatch feedback
GET/api/v1/email/configFetch per-user config
PUT/api/v1/email/configUpdate per-user config
POST/api/v1/email/vipAdd VIP sender
DELETE/api/v1/email/vipRemove VIP sender
POST/api/v1/email/categorizeCategorize a single email
POST/api/v1/email/categorize/batchCategorize multiple emails
POST/api/v1/email/categorize/apply-labelApply category label
POST/api/v1/email/gmail/oauth/urlStart Gmail OAuth
POST/api/v1/email/gmail/oauth/callbackHandle Gmail callback
GET/api/v1/email/gmail/statusGmail connection status
GET/api/v1/email/context/boostCross-channel context boost
GET/api/email/daily-digestDaily digest stats (alias: /api/inbox/daily-digest)
POST/api/v1/email/followups/markMark follow-up
GET/api/v1/email/followups/pendingList pending follow-ups
POST/api/v1/email/followups/\{id\}/resolveResolve follow-up
POST/api/v1/email/followups/check-repliesCheck for replies
POST/api/v1/email/followups/auto-detectAuto-detect follow-ups
GET/api/v1/email/\{id\}/snooze-suggestionsSnooze suggestions
POST/api/v1/email/\{id\}/snoozeApply snooze
DELETE/api/v1/email/\{id\}/snoozeCancel snooze
GET/api/v1/email/snoozedList snoozed emails
GET/api/v1/email/categoriesList categories
POST/api/v1/email/categories/learnCategory feedback

Background Sync Services

Aragora includes background sync connectors for real-time inbox updates:

  • GmailSyncService uses Google Pub/Sub + History API
  • OutlookSyncService uses Microsoft Graph change notifications + delta queries

Both integrate with EmailPrioritizer and support state_backend settings (memory, redis, postgres) for tenant-isolated sync state.

from aragora.connectors.email import (
GmailSyncService,
GmailSyncConfig,
OutlookSyncService,
OutlookSyncConfig,
)

gmail = GmailSyncService(
tenant_id="tenant_123",
user_id="user_456",
config=GmailSyncConfig(
project_id="my-project",
topic_name="gmail-notifications",
subscription_name="gmail-sync-sub",
),
)

outlook = OutlookSyncService(
tenant_id="tenant_123",
user_id="user_456",
config=OutlookSyncConfig(
notification_url="https://api.example.com/webhooks/outlook",
),
)

Inbox Command Center APIs

The inbox command center exposes endpoints for quick actions and bulk operations:

MethodEndpointDescription
GET/api/inbox/commandFetch prioritized inbox
POST/api/inbox/actionsExecute quick action
POST/api/inbox/bulk-actionsExecute bulk action
POST/api/inbox/reprioritizeTrigger AI re-prioritization
GET/api/inbox/sender-profileSender profile

Score Single Email

POST /api/v1/email/prioritize
Content-Type: application/json

{
"email": {
"id": "msg_123",
"subject": "Urgent: Quarterly Review",
"from_address": "boss@company.com",
"body_text": "Please review by EOD...",
"labels": ["INBOX"]
},
"force_tier": null
}

Response:

{
"success": true,
"result": {
"email_id": "msg_123",
"priority": "high",
"confidence": 0.85,
"score": 0.78,
"tier_used": "tier_1_rules",
"rationale": "Urgency keywords detected; sender is VIP",
"processing_time_ms": 45
}
}

Rank Inbox

POST /api/v1/email/rank-inbox
Content-Type: application/json

{
"emails": [...],
"limit": 50
}

Fetch + Rank (Gmail Connected)

GET /api/v1/email/inbox?user_id=default&limit=50&labels=INBOX

Record Feedback

POST /api/v1/email/feedback
Content-Type: application/json

{
"email_id": "msg_123",
"action": "replied",
"email": {...}
}

Gmail OAuth Integration

1. Get OAuth URL

POST /api/v1/email/gmail/oauth/url
{
"user_id": "user_123",
"redirect_uri": "https://app.example.com/inbox/callback"
}

2. Handle Callback

POST /api/v1/email/gmail/oauth/callback
{
"code": "auth_code_from_google",
"state": "user_123",
"redirect_uri": "https://app.example.com/inbox/callback"
}

Gmail Operations API

Advanced Gmail endpoints for labels, threads, drafts, and message actions:

MethodEndpointDescription
POST/api/v1/gmail/labelsCreate label
GET/api/v1/gmail/labelsList labels
PATCH/api/v1/gmail/labels/\{id\}Update label
DELETE/api/v1/gmail/labels/\{id\}Delete label
POST/api/v1/gmail/messages/\{id\}/labelsModify message labels
POST/api/v1/gmail/messages/\{id\}/readMark read/unread
POST/api/v1/gmail/messages/\{id\}/starStar/unstar
POST/api/v1/gmail/messages/\{id\}/archiveArchive message
POST/api/v1/gmail/messages/\{id\}/trashTrash/untrash
POST/api/v1/gmail/filtersCreate filter
GET/api/v1/gmail/filtersList filters
DELETE/api/v1/gmail/filters/\{id\}Delete filter
GET/api/v1/gmail/threadsList threads
GET/api/v1/gmail/threads/\{id\}Get thread
POST/api/v1/gmail/threads/\{id\}/archiveArchive thread
POST/api/v1/gmail/threads/\{id\}/trashTrash thread
POST/api/v1/gmail/threads/\{id\}/labelsModify thread labels
POST/api/v1/gmail/draftsCreate draft
GET/api/v1/gmail/draftsList drafts
GET/api/v1/gmail/drafts/\{id\}Get draft
PUT/api/v1/gmail/drafts/\{id\}Update draft
DELETE/api/v1/gmail/drafts/\{id\}Delete draft
POST/api/v1/gmail/drafts/\{id\}/sendSend draft
GET/api/v1/gmail/messages/\{id\}/attachments/\{attachment_id\}Get attachment

Notes:

  • Gmail operations require a connected Gmail account via the OAuth flow.
  • Pass user_id in query params for GET requests and in the JSON body for write requests.

Outlook Integration

Outlook/Microsoft 365 email integration is available under /api/v1/outlook.

MethodEndpointDescription
GET/api/v1/outlook/oauth/urlOAuth authorization URL
POST/api/v1/outlook/oauth/callbackOAuth callback
GET/api/v1/outlook/foldersList mail folders
GET/api/v1/outlook/messagesList messages
GET/api/v1/outlook/messages/\{id\}Get message details
GET/api/v1/outlook/conversations/\{id\}Get conversation thread
POST/api/v1/outlook/sendSend new message
POST/api/v1/outlook/replyReply to message
GET/api/v1/outlook/searchSearch messages
POST/api/v1/outlook/messages/\{id\}/readMark read/unread
POST/api/v1/outlook/messages/\{id\}/moveMove message
DELETE/api/v1/outlook/messages/\{id\}Delete message

Inbox UI Surfaces

The control plane UI includes inbox components for daily summary, bulk actions, and sender-level insights:

  • DailyDigestWidget (aragora/live/src/components/inbox/DailyDigestWidget.tsx) renders a daily digest panel and calls /api/email/daily-digest with a local mock fallback.
  • CommandCenter (aragora/live/src/components/inbox/CommandCenter.tsx) powers the inbox command center experience and bulk operations.
  • PriorityInboxList (aragora/live/src/components/inbox/PriorityInboxList.tsx) renders prioritized inbox items and scoring metadata.
  • QuickActionsBar (aragora/live/src/components/inbox/QuickActionsBar.tsx) provides single-email and bulk actions (archive, snooze, reprioritize).
  • SenderInsightsPanel (aragora/live/src/components/inbox/SenderInsightsPanel.tsx) surfaces sender profile statistics, AI analysis, and quick actions.
  • FollowUpPanel (aragora/live/src/components/inbox/FollowUpPanel.tsx) highlights pending follow-ups and overdue threads.
  • SnoozePanel (aragora/live/src/components/inbox/SnoozePanel.tsx) shows smart snooze suggestions.
  • TriageRulesPanel (aragora/live/src/components/inbox/TriageRulesPanel.tsx) manages inbox triage rules and automations.
  • InboxStatsCards (aragora/live/src/components/inbox/InboxStatsCards.tsx) summarizes inbox KPIs.
  • SharedInboxWidget (aragora/live/src/components/inbox/SharedInboxWidget.tsx) links shared inbox metrics into the inbox UI.

Shared Inbox & Routing Rules

Collaborative inbox workflows (assignment, status, routing rules) are exposed via the shared inbox API and UI. See SHARED_INBOX.md for the endpoints and workflow model.

Sender History Service

Tracks sender reputation and interaction patterns:

from aragora.services.sender_history import SenderHistoryService

service = SenderHistoryService(db_path="sender_history.db")
await service.initialize()

# Record interaction
await service.record_interaction(
user_id="user@example.com",
sender_email="important@company.com",
action="replied",
response_time_minutes=30,
)

# Get reputation
reputation = await service.get_sender_reputation(
user_id="user@example.com",
sender_email="important@company.com",
)

print(f"Reputation: {reputation.reputation_score}")
print(f"Category: {reputation.category}") # vip, important, normal, low_priority

Reputation Factors

FactorWeightDescription
Open Rate40%Percentage of emails opened
Reply Rate40%Percentage of emails replied to
Recency20%Bonus for recent interactions
VIP Status+0.3Manual VIP designation
Fast Responder+0.1Avg response < 30 mins

Spam & Threat Intelligence

Email prioritization integrates spam classification and threat intelligence for phishing detection and malicious URL/IP screening.

  • aragora/services/spam_classifier.py provides ML-backed spam scoring.
  • aragora/services/threat_intelligence.py checks URLs, IPs, and hashes.
  • aragora/server/handlers/threat_intel.py exposes /api/v1/threat/* endpoints.

Follow-Up Tracker

Tracks sent emails that are awaiting replies and surfaces overdue follow-ups.

from datetime import datetime, timedelta
from aragora.services.followup_tracker import FollowUpTracker

tracker = FollowUpTracker()

item = await tracker.mark_awaiting_reply(
email_id="msg_123",
thread_id="thread_456",
subject="Vendor security review",
recipient="security@vendor.com",
expected_by=datetime.now() + timedelta(days=3),
)

pending = await tracker.get_pending_followups(user_id="default")

Notes:

  • The follow-up tracker uses in-memory storage by default.
  • For production, persist follow-ups to a durable store.

Snooze Recommender

Provides smart snooze suggestions based on sender patterns, work schedule, and optional calendar availability.

from aragora.services.snooze_recommender import SnoozeRecommender

recommender = SnoozeRecommender(sender_history=service)
recommendation = await recommender.recommend_snooze(email, priority_result)

for suggestion in recommendation.suggestions:
print(suggestion.label, suggestion.snooze_until, suggestion.reason.value)

Notes on Persistence

  • Sender history uses SQLite for local persistence.
  • Follow-ups and snooze recommendations are in-memory by default.
  • For multi-instance deployments, use a shared store for user state.