Use Case: Email Automation
inbox triage ยท draft replies ยท newsletters ยท lead follow-up
What you'll build
An agent that reads your Gmail, triages by priority, drafts replies in your voice, and sends scheduled emails โ newsletters, follow-ups, or outreach โ on a cron schedule. Every send requires your approval unless you explicitly opt out.
Jump to section
Skills you need
| Skill | What it unlocks | Required? |
|---|---|---|
| gmail-reader | Read inbox, search emails, fetch threads | Core |
| gmail-sender | Send and reply to emails (always requires confirmation by default) | Core |
| email-drafter | Draft replies matching your writing style โ saves as draft, you review before sending | Recommended |
| gmail-labeler | Apply labels, archive, mark as read โ for triage automation | Recommended |
| notion-crm | Log email interactions to a Notion contacts database | Optional |
| web-search | Research email senders before drafting a reply | Optional |
Gmail OAuth setup
The Gmail skill uses OAuth 2.0. You need to create a Google Cloud project and authorise the agent once โ after that it stores a refresh token and works automatically.
- Go to console.cloud.google.com โ New Project
- Enable the Gmail API under APIs & Services โ Library
- Under OAuth consent screen, set user type to External and add your email as a test user
- Under Credentials, create an OAuth 2.0 Client ID โ Desktop app โ Download the JSON
- Save it as
gmail-credentials.jsonin your OpenClaw workspace
{
"skills": [
"official-gmail-reader",
"official-gmail-sender",
"official-email-drafter",
"official-gmail-labeler"
],
"model": "claude-sonnet-4-5",
"soulPath": "./SOUL.md",
"env": {
"GMAIL_CREDENTIALS_PATH": "./gmail-credentials.json"
},
"channel": {
"type": "telegram",
"token": "YOUR_BOT_TOKEN",
"chatId": "YOUR_CHAT_ID"
}
}On first run, the agent will print an authorisation URL. Open it in a browser, grant access, and the token will be saved automatically for future runs.
SOUL.md template
# Email Assistant
You help manage my email inbox: triage, draft replies, and send scheduled emails.
## Identity
- Name: MailBot
- Tone: Match the sender's tone โ professional for business, casual for friends
## Triage rules
When asked to check the inbox:
1. List unread emails from the last 24 hours
2. Mark each as: URGENT (needs reply today) / REVIEW (read but no reply needed) / SPAM (filter candidate)
3. For URGENT emails, draft a reply and show it to me for approval before sending
## Drafting rules
- Write in first person as me, not as an assistant
- Keep replies under 150 words unless the email is complex
- Never apologise unnecessarily
- End business emails with a clear next step or question
## Sending rules
- NEVER send an email without showing me the draft first and getting explicit approval ("yes send it" or "send")
- Exception: scheduled newsletters I have pre-approved in this SOUL file
## Pre-approved newsletters
- Weekly digest: every Monday 9am โ summarise last week's top AI news (max 300 words) and send to [email protected]Example tasks
Morning triage
"Check my inbox and triage emails from the last 12 hours. List urgent ones first."
Draft a reply
"Draft a reply to the last email from [email protected] โ thank him and say I'll review the article update this week"
Follow-up
"Find emails I haven't replied to in more than 3 days and draft follow-up responses"
Send newsletter
"Draft this week's newsletter: top 5 AI agent news from the last 7 days. Show me before sending."
Clean up
"Archive all emails older than 30 days that are already read and not starred"
Scheduled newsletters
Pre-approve specific newsletter sends in your SOUL.md so they run without confirmation. All other sends still require your approval.
{
"crons": [
{
"name": "Weekly AI newsletter",
"schedule": "0 9 * * 1",
"task": "Search for the top 5 AI agent news stories from the past week. Draft a newsletter under 300 words with source links. This is pre-approved โ send directly to [email protected]."
}
]
}Safety note: Only pre-approve sends for specific, well-defined newsletters with known recipient lists. For all ad-hoc replies, keep the default approval requirement. An accidental send is hard to undo.
Common issues
โ Gmail OAuth returns "access denied"
Your app is in "testing" mode and your email must be on the test user list. Go to Google Cloud Console โ OAuth consent screen โ Test users and add your email.
โ Agent sends email without asking
Make sure your SOUL.md includes the "NEVER send without approval" rule. If using cron-based sends, verify the task description does not say "send directly" unless intended.
โ Drafts don't sound like me
Add 2โ3 example emails you've written to your SOUL.md under a "Writing examples" section. The agent will match your style. Alternatively, specify tone explicitly: "formal", "direct", "warm".
โ Token expires after a few hours
Ensure your Google OAuth app has the offline_access scope. The gmail-reader skill should handle token refresh automatically if credentials.json is present.
Did this guide solve your problem?