email-content-compose/SKILL.md

2.1 KiB

Email Content Compose

All-in-one skill: fetch leads, compose personalized outreach emails, export as EML and upload to R2.

IMPORTANT — Execution Rules

  • This skill uses Bun + TypeScript. Do NOT create Python scripts.
  • Do NOT overwrite existing files in this skill directory.
  • Use the existing CLI scripts below. Do NOT write your own upload/compose logic.

Phases

1. Fetch (scripts/fetch.ts)

Retrieves the lead-dataset for a completed cold-outreach workflow.

cd ~/clawd/skills/email-content-compose
bun run fetch -- --workflow-id=<id>

Returns: JSON with businesses (name, website, reviews, emails) and summary stats.

2. Compose (LLM)

The LLM agent reads fetch output and composes a personalized email per business. Save drafts as a JSON array file. Each draft must have:

  • recipient_email (string)
  • recipient_name (string | null)
  • subject (string, under 60 chars)
  • body_html (string, professional HTML with inline styles)
  • body_text (string, plain text fallback)

Email Composition Rules

  • Reference the business name and specific review insights
  • Mention pain points or strengths identified from reviews
  • Tone: professional, consultative, not salesy
  • Save the drafts array to a temp JSON file, e.g. /tmp/drafts-<workflow-id>.json

3. Export (scripts/export.ts)

Converts drafts to RFC 5322 EML files, uploads individual EMLs + ZIP bundle to R2.

cd ~/clawd/skills/email-content-compose
bun run export -- --drafts=/tmp/drafts-<workflow-id>.json --workflow-id=<id> [--from=<email>] [--dry-run]

Returns: JSON with per-file R2 URLs and a bundle.zip URL.

Full Pipeline Example

cd ~/clawd/skills/email-content-compose

# 1. Fetch leads
bun run fetch -- --workflow-id=outreach-xxx > /tmp/leads.json

# 2. LLM composes drafts → saves to /tmp/drafts-outreach-xxx.json

# 3. Export EML + upload to R2
bun run export -- --drafts=/tmp/drafts-outreach-xxx.json --workflow-id=outreach-xxx

Environment (.env.local)

Already configured. Do NOT modify.

  • AUTH_BASE, CLIENT_KEY: for lead-dataset API auth
  • CLOUDFLARE_*: R2 upload credentials
  • SENDER_EMAIL: From header in EML files