agentmail
AI agent email: autonomous email management, classification, response drafting, scheduling
What this skill does
# agentmail
## Purpose
This skill enables an AI agent to autonomously manage emails, including classification, response drafting, and scheduling, using AI-driven automation for efficient email handling.
## When to Use
Use this skill for high-volume email inboxes, automated customer support, personal productivity workflows, or integrating email tasks into broader AI agent operations to reduce manual intervention.
## Key Capabilities
- Classify emails based on content, sender, or keywords using machine learning models.
- Draft response emails with customizable templates and tone adjustments.
- Schedule email sends or follow-ups based on user-defined rules or calendar integration.
- Manage email threads by summarizing, prioritizing, or archiving based on criteria.
- Integrate with email providers via APIs for real-time operations.
## Usage Patterns
To use agentmail, invoke it via CLI or API calls, passing necessary parameters like email IDs or content. Always set the API key via environment variable `$AGENTMAIL_API_KEY`. For CLI, prefix commands with authentication flags. Example pattern: Fetch an email, classify it, draft a response, then schedule if needed. Chain commands in scripts for automation.
## Common Commands/API
CLI commands require Node.js environment; install via `npm install agentmail-cli`. API endpoints are under `https://api.openclaw.com/agentmail/v1`.
- **Classify an email:**
CLI: `agentmail classify --email-id 12345 --key $AGENTMAIL_API_KEY`
API: POST /api/agentmail/classify with JSON body: `{"email_id": "12345", "api_key": "$AGENTMAIL_API_KEY"}`
Code snippet:
```bash
curl -X POST https://api.openclaw.com/agentmail/v1/classify \
-H "Content-Type: application/json" \
-d '{"email_id": "12345", "api_key": "'$AGENTMAIL_API_KEY'"}'
```
- **Draft a response:**
CLI: `agentmail draft --email-id 12345 --tone professional --key $AGENTMAIL_API_KEY`
API: POST /api/agentmail/draft with body: `{"email_id": "12345", "tone": "professional", "api_key": "$AGENTMAIL_API_KEY"}`
Code snippet:
```javascript
const response = await fetch('https://api.openclaw.com/agentmail/v1/draft', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({email_id: '12345', tone: 'professional', api_key: process.env.AGENTMAIL_API_KEY})
});
```
- **Schedule an email:**
CLI: `agentmail schedule --email-content "Reply text" --send-at "2023-10-01T10:00:00Z" --key $AGENTMAIL_API_KEY`
API: POST /api/agentmail/schedule with body: `{"email_content": "Reply text", "send_at": "2023-10-01T10:00:00Z", "api_key": "$AGENTMAIL_API_KEY"}`
Config format: Use JSON for scheduling rules, e.g., `{"rules": [{"condition": "priority>high", "action": "schedule in 2 hours"}]}`.
## Integration Notes
Integrate agentmail with email services like Gmail or Outlook by providing OAuth tokens via config files (e.g., `config.json: {"provider": "gmail", "token": "$GMAIL_TOKEN"}`). For AI agent workflows, use webhooks to trigger on new emails (e.g., POST to /api/agentmail/webhook). Ensure compatibility by matching API versions; handle dependencies like Node.js v14+. To combine with other skills, export results as JSON and pipe to next command, e.g., `agentmail classify ... | jq '.category' | other-skill-process`.
## Error Handling
Check for HTTP status codes: 401 for auth failures (retry with `$AGENTMAIL_API_KEY`), 404 for missing emails (log and skip), 500 for server errors (exponential backoff). In CLI, use `--verbose` flag for detailed logs. Handle common issues like rate limits by adding delays (e.g., sleep 5 seconds after 429 response). Validate inputs before calls, e.g., ensure email IDs are strings via regex check: `if (!emailId.match(/^\d+$/)) throw new Error('Invalid email ID');`. Use try-catch in scripts for graceful recovery.
## Concrete Usage Examples
1. **Classify and respond to a support ticket email:** First, classify: `agentmail classify --email-id 67890 --key $AGENTMAIL_API_KEY`. If classified as "support", draft: `agentmail draft --email-id 67890 --tone helpful --key $AGENTMAIL_API_KEY`. Then schedule: `agentmail schedule --email-content $(cat response.txt) --send-at now --key $AGENTMAIL_API_KEY`. This automates ticket responses in a helpdesk workflow.
2. **Manage personal email scheduling:** Fetch unread emails via API, classify them: `curl -X POST https://api.openclaw.com/agentmail/v1/classify -d '{"email_id": "54321", "api_key": "'$AGENTMAIL_API_KEY'"}'`. For high-priority, draft and schedule: `agentmail draft --email-id 54321 --tone formal --key $AGENTMAIL_API_KEY; agentmail schedule --email-content "Follow up" --send-at "tomorrow" --key $AGENTMAIL_API_KEY`. Use in a daily script for inbox zero.
## Graph Relationships
- Related to: email (direct), ai (cluster), agent (cluster), automation (tag).
- Connected clusters: community (same as this skill).
- Dependencies: May require skills like "email-parser" for input preprocessing or "scheduler" for advanced timing.
Related in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.