feat: add structured compose guidelines with sender profile, i18n, and review analysis

Enhance email composition with sender identity (sender-profile.json),
auto language selection by country, review pain-point analysis workflow,
structured email template, and personalization tracking.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
ywkj 2026-03-20 07:27:49 +08:00
parent 27b204b5fb
commit f258f48cdb
3 changed files with 58 additions and 4 deletions

View File

@ -28,10 +28,53 @@ Save drafts as a JSON array file. Each draft must have:
- `subject` (string, under 60 chars)
- `body_html` (string, professional HTML with inline styles)
- `body_text` (string, plain text fallback)
- `personalization_context` (object, see below)
#### Email Composition Rules
- Reference the business name and specific review insights
- Mention pain points or strengths identified from reviews
#### a) Sender Profile
Before composing, read `sender-profile.json` in this skill directory. Use it to populate sender identity, product info, and signature in every email.
#### b) Language Selection
Auto-select email language based on the `country` field from fetch output:
- us/gb/au/ca → English
- cn → 中文
- jp → 日本語
- kr → 한국어
- de → Deutsch
- fr → Français
- es/mx → Español
- pt/br → Português
- Unlisted countries → default to English
Write the **entire** email (subject, body, signature) in the selected language.
#### c) Review Pain-Point Analysis
When `reviews_data` is non-empty for a business:
1. Parse JSON into a review array
2. Filter for negative reviews / complaints related to the sender's `product_category`
3. Extract 12 pain points that the sender's products can solve
4. Analyze at most 10 reviews, prioritizing low-score ones
5. If `reviews_data` is empty or null, fall back to the business's general info (category, rating) to craft the email
#### d) Email Template Structure
1. **Subject** — Under 60 chars, in the target language, referencing a specific pain point or business need
2. **Opening** — Address the business by name; demonstrate familiarity with their operations
3. **Pain Point Bridge** — Reference pain-point patterns from reviews (do NOT quote reviews verbatim); connect them to problems the sender's product solves
4. **Value Proposition** — Introduce sender company and products using `product_highlights` from sender-profile.json
5. **CTA** — Low-friction call-to-action: free samples, catalog, or a brief call
6. **Signature** — Use contact info from sender-profile.json (name, title, email, phone, website)
#### e) Personalization Tracking
Populate the `personalization_context` field on each draft:
```json
{
"language": "selected language",
"pain_points_used": ["pain point 1", "pain point 2"],
"reviews_analyzed": true,
"sender_product_match": "brief note on how sender product connects to this business"
}
```
#### General Rules
- Tone: professional, consultative, not salesy
- Save the drafts array to a temp JSON file, e.g. `/tmp/drafts-<workflow-id>.json`

View File

@ -6,7 +6,7 @@ interface:
This skill uses Bun+TypeScript CLI scripts. Do NOT create Python scripts or custom upload logic.
Step 1: cd ~/clawd/skills/email-content-compose && bun run fetch -- --workflow-id=<WORKFLOW_ID>
Step 2: Read the fetch output. For each business with emails, compose a personalized EmailDraft (recipient_email, recipient_name, subject, body_html, body_text). Save all drafts as a JSON array to /tmp/drafts-<WORKFLOW_ID>.json
Step 2: Read sender-profile.json from the skill directory. Then read the fetch output. For each business with emails, compose a personalized EmailDraft following SKILL.md Section 2 rules (language selection by country, review pain-point analysis, structured email template, personalization_context tracking). Save all drafts as a JSON array to /tmp/drafts-<WORKFLOW_ID>.json
Step 3: bun run export -- --drafts=/tmp/drafts-<WORKFLOW_ID>.json --workflow-id=<WORKFLOW_ID>
Return the export result JSON (file URLs + bundle URL). Read SKILL.md for composition rules.

11
sender-profile.json Normal file
View File

@ -0,0 +1,11 @@
{
"company_name": "Your Company Name",
"website": "https://yourcompany.com",
"product_category": "e.g., industrial packaging supplies",
"product_highlights": ["Key benefit 1", "Key benefit 2"],
"value_proposition": "One sentence why businesses should use your products",
"contact_name": "Sales Rep Name",
"contact_title": "Business Development Manager",
"contact_email": "sales@yourcompany.com",
"contact_phone": "+1-555-0100"
}