Process change requests on InboxMate email drafts. Reads drafts with pending change requests from the notification service API, applies the requested changes to the email HTML, and updates the drafts. Run after adding change requests via the admin UI.
Announce:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Email Draft Refinement started. Checking environment... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
The notification service at notifications.psquared.dev stores email drafts that are reviewed before sending. Admins can attach "change requests" to drafts (e.g., "make this per du", "shorten the intro", "add a line about their pricing page"). This skill picks up those change requests, reads each draft's current HTML, applies the changes, and saves the updated version.
The drafts are InboxMate outreach emails — personalized cold emails sent to Austrian/German businesses to show them an AI chatbot demo we built for their company. Each email has:
Important: The email HTML is the final rendered output. When you edit it, you're editing raw HTML — preserve all styling, tags, and structure. Only change the text content as requested.
Read .env using the Read tool (do NOT source it). Extract:
EMAIL_DRAFT_ONLY_BEARER — bearer token for the notification service draft API. This token can read, create, and update drafts but cannot send, schedule, or delete them. Sending is human-only via the admin UI.The notification service base URL is https://notifications.psquared.dev.
Once verified:
Environment OK. Finding drafts with change requests...
Query the notification service API for DRAFT-status emails with change requests:
curl -s -X GET "https://notifications.psquared.dev/drafts?status=DRAFT&hasChangeRequest=true&pageSize=50" \
-H "Authorization: Bearer $EMAIL_DRAFT_ONLY_BEARER"
This returns { success: true, data: { data: [...], total: N } }. Each draft object contains:
id — draft UUIDsubject — email subjecthtml_body — full rendered HTMLtext_body — plain text versionchange_request — the requested change (string)recipient_email — recipientcrm_company_name — company namelocale — de or enIf none found (empty array or total=0), announce "No drafts with change requests" and stop.
Announce:
Found [N] drafts with change requests: 1. [Company] — "[change request]" 2. [Company] — "[change request]"
For each draft with a change request:
The html_body contains the full rendered email. Parse it to understand the current text content. The structure is:
{{greeting}} → first <p> after the header divider{{bodyParagraph1}} → second <p>{{bodyParagraph2}} → third <p> (optional){{bodyParagraph3}} → fourth <p> (optional)<a> with background-color:#10b981<p> inside the green #ecfdf5 div (optional)<p> in the green div<p> after the green div<p> with color:#10b981 and font-style:italicRead the change_request text and apply it. Common requests:
After making changes:
Update the draft via the notification service API:
curl -s -X PUT "https://notifications.psquared.dev/drafts/[draftId]" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $EMAIL_DRAFT_ONLY_BEARER" \
-d '{"html_body": "[updated HTML]", "change_request": null}'
Important: Set change_request to null after applying — this marks it as processed.
If the change request also affects the subject:
curl -s -X PUT "https://notifications.psquared.dev/drafts/[draftId]" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $EMAIL_DRAFT_ONLY_BEARER" \
-d '{"html_body": "[updated HTML]", "subject": "[new subject]", "change_request": null}'
Announce after each:
Refined: [Company] — applied "[change request]"
Announce:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Email Draft Refinement complete. Refined: [N] - [Company A] — "per du" applied - [Company B] — "shorten intro" applied Next step: Review refined drafts at → notifications.psquared.dev/drafts ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━