← Back to Blog

How to Run an AI Email Automation Agent with OE Runtime

Read your Gmail inbox, prioritise what needs a reply, and send professional follow-up emails automatically. OE Runtime connects to Gmail via the REST API using OAuth — no SMTP configuration, no app passwords, and no SDK required.

📧
Step 1
Read Inbox
Fetch the 10 most recent unread emails with sender, subject, date, and a one-sentence summary.
Step 2
Draft & Send Reply
Identify the most urgent email and send a professional acknowledgement reply via the Gmail REST API.
Step 3
Report
Summarise emails found, which was replied to, and confirm delivery with timestamp.

What You Need


Create the Project Folder

Create a folder called email/ and add these two files:

email/
├── SKILL.md         # the portable skill (agentskills.io)
├── agent.yaml       # wires SKILL.md to your connector
└── oe-config.json  # LLM key + connector credentials

The Skill Files

Create SKILL.md inside an email/ directory. This is the portable skill — it follows the agentskills.io format and runs unchanged on Claude, Cursor, Windsurf, or OE Runtime:

---
name: email
description: Summarize inbox and send a follow-up email
license: Apache-2.0
metadata:
  author: Open Enthrium
  version: "1.0"
---

You are an email assistant. Read the inbox and send emails via the Gmail REST API.
Draft professional, concise messages. Never send without confirming recipient and subject.
Complete all steps fully before writing your report.

## Step 1: Read Inbox
Call the Gmail connector:
GET /messages with params: { "labelIds": "UNREAD", "maxResults": "10" }
Then for each message id returned, call:
GET /messages/<id> with params: { "format": "metadata", "metadataHeaders": "From,Subject,Date" }
Collect sender, subject, date, and snippet for each email.

## Step 2: Draft and Send Reply
From the unread emails, identify the one that most urgently needs a reply.
Draft a professional acknowledgement reply. Then send it by calling:
POST /messages/send
with body: { "raw": "<base64url-encoded RFC 2822 message>" }
Construct the raw field as: base64url("From: me\r\nTo: <sender>\r\nSubject: Re: <subject>\r\n\r\n<body>")

## Step 3: Report
Summarize what was done:
- Number of unread emails found
- Brief summary of each email (sender, subject, urgency level)
- Which email was replied to and why
- Confirm the reply was sent successfully

Create agent.yaml in the same directory to wire the skill to your connector:

name: Email Assistant
description: Summarize inbox and send a follow-up email
connectors:
  - connection_name: My Email
    connection_type: gmail-rest
skills:
  - path: ./
    trigger_type: auto

The Config File

Create oe-config.json in the same directory:

{
  "llm": {
    "provider": "openai",
    "model": "gpt-4o",
    "apiKey": "YOUR_OPENAI_API_KEY"
  },
  "server": {
    "enabled": false,
    "port": 3333,
    "apiKey": "your-secret-api-key"
  },
  "connectors": [
    {
      "connection_name": "My Email",
      "connection_type": "gmail-rest",
      "bearerToken": "YOUR_GOOGLE_ACCESS_TOKEN",
      "baseUrl": "https://gmail.googleapis.com/gmail/v1/users/me"
    }
  ]
}

How to Get Your Bearer Token

  1. Go to Google Cloud Console → create a new project or select an existing one
  2. Go to APIs & Services → Library → search for Gmail API → click Enable
  3. Go to APIs & Services → Credentials → Create Credentials → OAuth 2.0 Client ID
  4. Set Application type to Desktop app → click Create → note your Client ID and Client Secret
  5. Open the Google OAuth 2.0 Playground
  6. Click the ⚙️ gear icon (top right) → enable Use your own OAuth credentials → paste your Client ID and Client Secret
  7. In Step 1, find Gmail API v1 → select scope https://www.googleapis.com/auth/gmail.modify → click Authorize APIs
  8. Sign in with your Google account and allow access
  9. In Step 2, click Exchange authorization code for tokens
  10. Copy the Access Token and paste it as bearerToken in your oe-config.json

⚠️ Access tokens expire after 1 hour. For scheduled or automated use, save the Refresh Token and exchange it for a new access token before each run.

Download OE Runtime

OE Runtime — Direct Downloads

Run the Agent

From the parent folder containing your skill directory:

MethodBest forDownload
1 npx recommended No install needed — always runs the latest version —
2 Windows .exe Download once, run offline on Windows ⊞ Windows (.exe)
3 macOS binary Download once, run offline on Mac  macOS
4 Linux binary Server deployments, cron jobs, Docker 🐧 Linux
5 API Server integration Call from any app, webhook, or automation pipeline 📮 Postman Collection

1 npx recommended

npx -y @openenthrium/oe-runtime@latest ./email

2 Windows

oe-runtime-win.exe ./email

3 macOS

chmod +x oe-runtime-macos
./oe-runtime-macos ./email

First run blocked? System Settings → Privacy & Security → Allow Anyway.

4 Linux

chmod +x oe-runtime-linux
./oe-runtime-linux ./email

5 API Server integration

Add a "server" block to oe-config.json, then start with --serve:

{
  "llm": { ... },
  "server": { "enabled": true, "port": 3333, "apiKey": "your-secret-key" },
  "connectors": [ ... ]
}
npx -y @openenthrium/oe-runtime@latest --serve --config oe-config.json

Run with inline YAML:

curl -X POST http://localhost:3333/run \
  -H "Content-Type: application/json" \
  -H "X-API-Key: your-secret-key" \
  -d '{"yaml": "...", "params": {}}'

Or run from a file on the server:

curl -X POST http://localhost:3333/run-file \
  -H "Content-Type: application/json" \
  -H "X-API-Key: your-secret-key" \
  -d '{"file": "/path/to/agent.yaml", "params": {}}'

Use Cases

Build your own agents with OE Runtime

Download OE Runtime and run any AI agent locally or as a server — no cloud required.

Get OE Runtime →
Series OE Runtime Agent Guides — 21 Connectors
Series overview →