๐ง Generative AI for BusinessMay 21, 2026โ
Tests passing
AI Email Generator
A CLI tool that allows users to generate professional-quality business emails using generative AI models like Claude. Users can specify tone, purpose, and key points for the email, making it ideal for automating repetitive email creation tasks.
What It Does
- Generate emails with a specified tone (e.g., formal, casual).
- Specify the purpose of the email (e.g., follow-up, introduction).
- Include key points to be addressed in the email.
- Save the generated email to a file or display it directly in the terminal.
Installation
1. Clone the repository:
git clone <repository-url>2. Install dependencies:
pip install -r requirements.txtUsage
1. Set the OPENAI_API_KEY environment variable with your OpenAI API key.
export OPENAI_API_KEY=your_api_key_here2. Run the CLI tool:
python ai_email_generator.py --tone "formal" --purpose "follow-up" --key_points "meeting recap, next steps" --output_file "email.txt"--tone: Tone of the email (e.g., formal, casual).--purpose: Purpose of the email (e.g., follow-up, introduction).--key_points: Key points to include in the email.--output_file: (Optional) File to save the generated email.
Source Code
import openai
import click
from pydantic import BaseModel, ValidationError, constr
import os
class EmailRequest(BaseModel):
tone: constr(min_length=1)
purpose: constr(min_length=1)
key_points: constr(min_length=1)
def to_prompt(self):
return (
f"Generate a {self.tone} email for the following purpose: {self.purpose}. "
f"Include the following key points: {self.key_points}."
)
def generate_email(api_key, email_request):
openai.api_key = api_key
try:
response = openai.Completion.create(
engine="text-davinci-003",
prompt=email_request.to_prompt(),
max_tokens=300,
temperature=0.7,
)
return response.choices[0].text.strip()
except Exception as e:
raise RuntimeError(f"Failed to generate email: {e}")
@click.command()
@click.option('--tone', required=True, help='Tone of the email (e.g., formal, casual).')
@click.option('--purpose', required=True, help='Purpose of the email (e.g., follow-up, introduction).')
@click.option('--key_points', required=True, help='Key points to include in the email.')
@click.option('--output_file', default=None, help='File to save the generated email.')
def main(tone, purpose, key_points, output_file):
"""AI Email Generator: Generate professional-quality business emails."""
api_key = os.getenv("OPENAI_API_KEY")
if not api_key:
click.echo("Error: OPENAI_API_KEY environment variable is not set.")
return
try:
email_request = EmailRequest(tone=tone, purpose=purpose, key_points=key_points)
email_content = generate_email(api_key, email_request)
if output_file:
with open(output_file, 'w') as f:
f.write(email_content)
click.echo(f"Email saved to {output_file}")
else:
click.echo("Generated Email:")
click.echo(email_content)
except ValidationError as e:
click.echo(f"Input validation error: {e}")
except RuntimeError as e:
click.echo(f"Error: {e}")
if __name__ == "__main__":
main()
Community
Downloads
ยทยทยท
Rate this tool
No ratings yet โ be the first!
Details
- Tool Name
- ai_email_generator
- Category
- Generative AI for Business
- Generated
- May 21, 2026
- Tests
- Passing โ
- Fix Loops
- 3
Quick Install
Clone just this tool:
git clone --depth 1 --filter=blob:none --sparse \ https://github.com/ptulin/autoaiforge.git cd autoaiforge git sparse-checkout set generated_tools/2026-05-21/ai_email_generator cd generated_tools/2026-05-21/ai_email_generator pip install -r requirements.txt 2>/dev/null || true python ai_email_generator.py