$npx -y skills add opendatahub-io/ai-helpers --skill gmail-draftUse this skill to compose a Gmail draft from text content in the conversation. Accepts a body, recipient list, and subject — either from the user or from context — and creates a draft in the user's Gmail Drafts folder via gws.
| 1 | # Gmail Draft |
| 2 | |
| 3 | Compose a Gmail draft from text content provided in the conversation. |
| 4 | |
| 5 | ## Prerequisites |
| 6 | |
| 7 | - `gws` binary must be on `$PATH` |
| 8 | - Authenticated with Gmail compose scope: run `gws auth login` (not `--readonly`) |
| 9 | |
| 10 | If `gws` is not installed or authentication fails, tell the user to follow the |
| 11 | setup instructions in the `google-workspace` skill. |
| 12 | |
| 13 | Helper scripts are located in `${CLAUDE_SKILL_DIR}` and require Python 3.10+. |
| 14 | |
| 15 | --- |
| 16 | |
| 17 | ## Step 1: Gather Recipients, Subject, and Body |
| 18 | |
| 19 | Collect the three required inputs. Sources depend on how the skill was invoked: |
| 20 | |
| 21 | - **From another skill** (e.g. `email-meeting-summary`): recipients, subject, |
| 22 | and body are passed in context — use them directly. |
| 23 | - **Standalone invocation**: use `AskUserQuestion` to collect any that are |
| 24 | missing: |
| 25 | - Recipients: "Who should receive this email? (comma-separated addresses)" |
| 26 | - Subject: "What should the subject line be?" |
| 27 | - Body: "Paste or describe the content you want in the email body." |
| 28 | |
| 29 | --- |
| 30 | |
| 31 | ## Step 2: Present for Review |
| 32 | |
| 33 | Show the user the draft details before creating: |
| 34 | |
| 35 | ```text |
| 36 | To: <recipients> |
| 37 | Subject: <subject> |
| 38 | |
| 39 | <body> |
| 40 | ``` |
| 41 | |
| 42 | Ask: |
| 43 | |
| 44 | > "Does this look right? Reply with any edits, or say 'send' to create the |
| 45 | > draft." |
| 46 | |
| 47 | Incorporate edits and re-present until the user approves. |
| 48 | |
| 49 | --- |
| 50 | |
| 51 | ## Step 3: Create the Draft |
| 52 | |
| 53 | Write the body to a temp file, then call `create_draft.py`: |
| 54 | |
| 55 | ```bash |
| 56 | BODY_FILE=$(mktemp /tmp/gmail_draft_body.XXXXXX) |
| 57 | cat > "$BODY_FILE" << 'BODY_EOF' |
| 58 | <approved body text> |
| 59 | BODY_EOF |
| 60 | |
| 61 | python3 "${CLAUDE_SKILL_DIR}/scripts/create_draft.py" \ |
| 62 | --to "<recipients>" \ |
| 63 | --subject "<subject>" \ |
| 64 | --body-file "$BODY_FILE" |
| 65 | ``` |
| 66 | |
| 67 | --- |
| 68 | |
| 69 | ## Step 4: Confirm |
| 70 | |
| 71 | On success, tell the user: |
| 72 | |
| 73 | > "Draft created. You can find it in the Drafts folder in Gmail at |
| 74 | > https://mail.google.com/mail/#drafts. Review it before sending." |
| 75 | |
| 76 | If the script exits with an error, show the error message and suggest the user |
| 77 | check `gws auth login` permissions (the Gmail scope must include draft |
| 78 | creation). |
| 79 | |
| 80 | --- |
| 81 | |
| 82 | ## Error Reference |
| 83 | |
| 84 | | Situation | Action | |
| 85 | |---|---| |
| 86 | | `gws` not found | Tell user to install `gws` and add it to PATH | |
| 87 | | Auth error (401/403) | Tell user to run `gws auth login` (without `--readonly`) | |
| 88 | | `create_draft.py` fails | Show error; check Gmail scope in `gws auth login` | |