task icon Task

Create Email Draft

Compose and save an email draft in Gmail

Requirements
to (email address, optional if unknown), subject (optional), content or intent (what to say, can be rough notes), threadId (optional, for replies)
5

Check what's already provided in requirements. Only ask for what's missing:

  • to: recipient email (skip if already known)
  • subject: what it's about (skip if already known)
  • content: what to say (skip if already known)

If all are provided, proceed directly to composing.

6

Compose the email body matching the user's gmail writing style from stateUser Analysis Results (file: writing-style.md).

Write a preview draft with _action frontmatter:


_action:
label: "Save draft"
prompt: "Create this Gmail draft using the content below. Format body as HTML."
isComplete: false

To: [recipient]
Subject: [subject]

[body]

Sauna displays this as a preview card with a "Save draft" button.
User can edit the content, then click to save.

8

Check the result. If successful:
"Draft saved. Open Gmail to review and send when ready."

If failed, explain the error.

                    To run this task you must have the following required information:

> to (email address, optional if unknown), subject (optional), content or intent (what to say, can be rough notes), threadId (optional, for replies)

If you don't have all of this information, exit here and respond asking for any extra information you require, and instructions to run this task again with ALL required information.

---

You MUST use a todo list to complete these steps in order. Never move on to one step if you haven't completed the previous step. If you have multiple CONSECUTIVE read steps in a row, read them all at once (in parallel). Otherwise, do not read a file until you reach that step.

Add all steps to your todo list now and begin executing.

## Steps

1. [Read External Actions Guide]: Read the documentation in: `skills/sauna/[skill_id]/references/sauna.actions.external.md` (Preview UI pattern for external actions)

2. [Read Email Drafting Guidelines]: Read the documentation in: `skills/sauna/[skill_id]/references/gmail.draft.rules.md` (Guidelines for drafting emails)

3. [Read User Analysis Results]: Discover relevant information in the user's filesystem at `documents/user/analysis/*.md`. (User's gmail writing style to match (file: writing-style.md))

4. [Read Domain Preferences]: Discover relevant information in the user's filesystem at `documents/preferences/[domain].md`. (Check for saved email preferences and past corrections (domain: email))

5. Check what's already provided in requirements. Only ask for what's missing:
- to: recipient email (skip if already known)
- subject: what it's about (skip if already known)
- content: what to say (skip if already known)

If all are provided, proceed directly to composing.


6. Compose the email body matching the user's gmail writing style from `documents/user/analysis/*.md` (file: writing-style.md).

Write a preview draft with _action frontmatter:

---
_action:
  label: "Save draft"
  prompt: "Create this Gmail draft using the content below. Format body as HTML."
  isComplete: false
---

**To:** [recipient]
**Subject:** [subject]

[body]

Sauna displays this as a preview card with a "Save draft" button.
User can edit the content, then click to save.


7. [Gather Arguments: Create Gmail Draft] The next step has the following requirements for arguments, do not proceed until you have all the required information:
- `to`: {{to}}
- `subject`: {{subject}}
- `body`: {{body}}
- `threadId`: {{threadId}}
- `outputPath` (default: "session/draft-result.json"): session/draft-result.json
- `htmlBody` - Optional HTML email body (creates multipart message)
- `inReplyTo` - Message-ID header from original message (for proper reply threading)
- `cc` - CC recipients (comma-separated)
- `bcc` - BCC recipients (comma-separated)

8. [Run Code: Create Gmail Draft]: Call `run_script` with:

```json
{
  "file": {
    "path": https://sk.ills.app/code/gmail.draft.create/preview,
    "args": [
      "to",
      "subject",
      "body",
      "threadId",
      "outputPath",
      "htmlBody",
      "inReplyTo",
      "cc",
      "bcc"
    ]
  },
  "packages": null
}
```

9. Check the result. If successful:
"Draft saved. Open Gmail to review and send when ready."

If failed, explain the error.