DEV Community

Qasim Muhammad
Qasim Muhammad

Posted on

nylas email smart-compose — AI-powered email composition — generate a draft from a text prompt

Scripts, cron jobs, and AI agents all need email access. nylas email smart-compose provides it without SMTP configuration.

The nylas email smart-compose command generates email content from a natural language prompt. Optionally pass --thread-id to give the AI context from an existing conversation so the reply matches tone and content.

Syntax

nylas email smart-compose --prompt PROMPT [--to EMAIL] [--thread-id THREAD_ID]
Enter fullscreen mode Exit fullscreen mode

Examples

Compose from a prompt:

nylas email smart-compose --prompt "Decline the meeting politely, suggest next week instead" --to colleague@company.com
Enter fullscreen mode Exit fullscreen mode

Reply in thread context:

nylas email smart-compose --prompt "Accept the proposal and ask about timeline" --thread-id thread_abc123
Enter fullscreen mode Exit fullscreen mode

Generate and send in one pipeline:

nylas email smart-compose --prompt "Thank them for the intro" --to partner@startup.com --json | nylas email send --from-draft --yes
Enter fullscreen mode Exit fullscreen mode

How It Works

The Nylas CLI abstracts away the differences between Gmail's API, Microsoft Graph, Exchange Web Services, and raw IMAP. You write one command; it works across all providers. This matters for automation — your cron job or CI pipeline doesn't need provider-specific logic.

Key Flags

Run nylas email smart-compose --help to see all available flags. Add --json for machine-readable output — useful when piping into jq or feeding data to scripts.

nylas email smart-compose --help
Enter fullscreen mode Exit fullscreen mode

Common Issues

Generated content is off-topic or generic
Pass --thread-id to give the AI conversation context. More specific prompts produce better results.

Command not found or not available
AI features require Nylas CLI v1.4+. Run nylas --version to check, then update with brew upgrade nylas-cli or re-run the install script.

Related Commands


Full docs: nylas email smart-compose reference — all flags, advanced examples, and troubleshooting.

All commands: Nylas CLI Command Reference

Get started: brew install nylas/nylas-cli/nylasother install methods

Top comments (0)