An Express.js-based API that uses LangChain and Groq to generate professional emails from brief summaries.
- Accepts a summary and returns a professionally drafted email.
- Uses Groq LLM (
llama-3.1-8b-instant
) via LangChain. - Clean modular architecture with Express routing and service layers.
- Node.js + Express.js – API backend
- LangChain – Prompt & LLM orchestration
- GroqCloud – LLM provider
- dotenv – For environment variables
project/
│
├── routes/
│ └── email.js # Route to handle /generate-email
│
├── services/
│ └── emailService.js # Uses LangChain + Groq to generate the email
│
├── .env # Environment config (GROQ_API_KEY, PORT)
├── server.js # Main entry point
└── package.json
git clone https://github.com/your-username/email-drafting-api.git
cd email-drafting-api
npm install
GROQ_API_KEY=your_groq_api_key
PORT=5000
node server.js
Server will run at:
http://localhost:5000
POST /generate-email
{
"summary": "Schedule a meeting with the client next week to discuss project milestones."
}
{
"email": "Dear [Client],\n\nI hope this message finds you well. I would like to schedule a meeting with you next week to discuss our project milestones..."
}
curl -X POST http://localhost:5000/generate-email \
-H "Content-Type: application/json" \
-d '{"summary": "Follow up with HR about the onboarding documents."}'
MIT License — free to use, modify, and share.
- GroqCloud
- LangChainJS
- Express.js