Skip to content
All Skills

Gmail Response Template Manager

Creates, stores, and applies reusable email response templates. Analyzes your common replies to build a template library, then auto-fills templates for quick Gmail draft creation. Prerequisites: gcloud, curl, jq, base64.

Email & Communication|v1|Updated 5/18/2026
MCP get_skill({ skillId: "gmail-response-template-manager-aff95a62" })

Use this skill with your agent

Create a free account and connect via MCP

Get Started Free
# Gmail Response Template Manager

Build a library of reusable email templates from your common reply patterns, then instantly create Gmail drafts from templates with smart variable substitution.

## When to Use

- "Create a template for client onboarding emails"
- "I keep writing the same reply to job applicants — make it a template"
- "Use my 'project update' template for the Acme team"
- "Analyze my sent emails and suggest templates I should create"

## Requirements

- **Google Cloud CLI** (`gcloud`) authenticated with Gmail API
- OAuth2 scopes: `gmail.readonly`, `gmail.compose`
- `jq` for JSON parsing
- Workspace folder for template storage: `templates/email/`

## Workflow

### Step 1 — Analyze Sent Mail for Patterns (Auto-Detect Mode)

When user says "suggest templates":

```bash
ACCESS_TOKEN=$(gcloud auth print-access-token)

# Fetch last 50 sent emails
curl -s -H "Authorization: Bearer $ACCESS_TOKEN" \
  "https://gmail.googleapis.com/gmail/v1/users/me/messages?q=in:sent&maxResults=50" | \
  jq -r '.messages[].id' > /tmp/sent_ids.txt

# Extract subjects and snippets
while read MSG_ID; do
  curl -s -H "Authorization: Bearer $ACCESS_TOKEN" \
    "https://gmail.googleapis.com/gmail/v1/users/me/messages/$MSG_ID?format=metadata&metadataHeaders=Subject" | \
    jq '{subject: (.payload.headers[] | select(.name=="Subject") | .value), snippet: .snippet}'
done < /tmp/sent_ids.txt
```

Group similar emails by subject/content patterns and suggest templates.

### Step 2 — Create Template File

Store templates as markdown with variable placeholders:

```bash
mkdir -p templates/email
cat > templates/email/client-onboarding.md << 'EOF'
---
name: Client Onboarding
subject: "Welcome aboard, {{CLIENT_NAME}}! Next steps for {{PROJECT_NAME}}"
variables:
  - CLIENT_NAME: "Client's first name"
  - PROJECT_NAME: "Name of the project"
  - START_DATE: "Project kick-off date"
  - ONBOARDING_DOC_LINK: "Link to onboarding document"
---

Hi {{CLIENT_NAME}},

Great to have you on board! Here's what happens next:

1. **Kick-off call** — scheduled for {{START_DATE}}
2. **Onboarding doc** — please review: {{ONBOARDING_DOC_LINK}}
3. **Slack channel** — I'll send you an invite separately

Let me know if you have any questions before we start.

Best,
{{SENDER_NAME}}
EOF
```

### Step 3 — Use a Template

When user says "use template X for Y":

1. Read the template file from `templates/email/`
2. Ask user for each variable value
3. Substitute variables into template
4. Show completed email for review

### Step 4 — Create Gmail Draft from Template

```bash
ACCESS_TOKEN=$(gcloud auth print-access-token)

# Substituted email content
ENCODED=$(echo -n "From: me\nTo: {RECIPIENT}\nSubject: {FILLED_SUBJECT}\nContent-Type: text/plain; charset=utf-8\n\n{FILLED_BODY}" | base64 -w 0 | tr '+/' '-_' | tr -d '=')

curl -s -X POST -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d "{\"message\": {\"raw\": \"$ENCODED\"}}" \
  "https://gmail.googleapis.com/gmail/v1/users/me/drafts"
```

### Step 5 — List Available Templates

When user says "show my templates":

```bash
for f in templates/email/*.md; do
  echo "---"
  head -10 "$f" | grep -E '^(name|subject):'
done
```

## Template Variables

Built-in variables auto-filled without asking:
- `{{SENDER_NAME}}` — from Gmail profile
- `{{TODAY}}` — current date
- `{{TOMORROW}}` — tomorrow's date

## Important Rules

- Never send — only create drafts
- Always show filled template before creating draft
- Store templates in workspace, not in Gmail
- Back up templates in git for version control

## Example Prompts

- "Create a template for project status update emails"
- "Show my email templates"
- "Use the onboarding template for Sarah at TechCorp"
- "Analyze my sent emails and suggest templates"
#gmail#templates#automation#productivitygcloudcurljqbase64