← All tutorialsEmail

Email triage from a real inbox

email.search for unreads, email.read to fetch bodies, GPT-4o-mini classifies + drafts, email.reply or email.draft based on confidence.

Cost~$0.01 per triaged email
Operations
email.searchemail.readtext_generation.generateemail.replyemail.draft

Prerequisites

  • Nylas (or Gmail OAuth) at /connected-apps.
  • email.search + email.read + email.reply + email.draft enabled.

Walkthrough

1. Find unreads

email.search with `q:'is:unread newer_than:1d'`. Returns message ids + previews.

bash# Search the inbox without burning a full read on every message.
curl -X POST https://www.upivia.com/v1/service-requests \
  -H "Authorization: Bearer $AGENT_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "service":"email",
    "operation":"search",
    "payload":{"q":"is:unread newer_than:1d","limit":50}
  }'

2. Read + classify

For each id: email.read then GPT-4o-mini returns {category, confidence, draft_reply}.

3. Reply or draft

confidence > 0.85 calls email.reply (sends). Otherwise email.draft (lands in their Drafts folder for a human pass). Either way it's audited.

Next steps

Audit every call at /audit-logs, watch spend at /usage, and tune budgets per service on the agent's page.

Create an account →