Guide
Draft Email with Smart Compose (CLI)
Writing the first draft is the slow part of email, and it's exactly what a model is good at. The Nylas CLI's smart-compose turns a short prompt into a drafted message, and pointed at an existing message it writes a reply that already has the thread's context. The draft is created, not sent, so a person reviews before it goes out. This guide covers composing fresh messages, context-aware replies, and the review-then-send workflow that keeps AI drafting safe.
Written by Pouya Sanooei Software Engineer
Command references used in this guide: nylas email smart-compose, nylas email drafts create, and nylas email read.
How do you draft an email with smart compose?
You draft an email by giving nylas email smart-compose a prompt describing what you want to say. The command returns generated body text — a first draft you refine — rather than sending anything. A prompt like “decline the meeting politely and propose next Tuesday” produces a complete message you can paste, edit, or save as a draft, which is faster than starting from a blank compose window.
Keep the prompt specific, because the output quality tracks the input. “Thank the customer, confirm the refund, and give a 5-7 day timeline” yields a usable draft; “write a reply” yields something generic. The model handles phrasing and structure; you supply the facts and intent. The broader Nylas message-intelligence capabilities are documented in the Nylas developer docs; treat the result as a draft to verify, not a finished message to trust blindly.
# Draft a fresh message from a prompt
nylas email smart-compose \
--prompt "Decline the meeting politely and propose next Tuesday at 2pm."How do you draft a context-aware reply?
For a reply, pass --message-id so smart compose reads the message you're responding to and drafts in context. Instead of describing the whole thread in your prompt, you point at it: the command pulls the original's content and your prompt steers the response. “Answer their pricing question and offer a call” against a real message produces a reply that already references what they asked.
This is where smart compose saves the most time — a reply that needs the thread's details otherwise means re-reading and summarizing before you write. Get the message ID from nylas email list or nylas email search, then draft against it. The reply is still a draft, so you confirm it captured the context correctly before it leaves your outbox.
# Find the message, then draft a reply with its context
nylas email search "subject:pricing" --json --limit 1 | jq -r '.[0].id'
nylas email smart-compose \
--message-id msg_abc123 \
--prompt "Answer their pricing question and offer a 20-minute call."Why review before sending?
Review every generated draft before sending because a model can be confidently wrong — a misremembered date, an over-promise, or a tone that doesn't fit the relationship. Smart compose deliberately produces a draft, not a sent message, so the human stays in the loop. Save the result with nylas email drafts create, read it, edit it, and send it yourself; the few seconds of review prevent the mistakes that erode trust.
This review step is the core guardrail for any AI-assisted email, and it matters more when smart compose runs inside an agent that reads untrusted content. A reply drafted from a message containing a prompt injection could carry an instruction you don't want to act on, which is why the draft-and-approve pattern — never an automatic send — is the safe default. For building that into an agent, see the human-in-the-loop guide.
Next steps
- Manage email drafts — save, edit, and send drafts
- Human-in-the-loop email agent — draft-and-approve in an agent
- Reply to email from the CLI — send the reply you drafted
- Summarize email threads with AI — condense before you reply
- Mark emails read, unread, or starred — flip flags from the CLI
- Full command reference — every flag and subcommand documented