FastAPI Projects
Email Automation AI-Growth Project
AI-Powered Follow-Up Email Automation (v1.0)
Role • AI / Back-End & Workflow Engineer Stack : FastAPI · Hugging Face LLM (zephyr-7b-beta) · n8n · Google Sheets API · Gmail SMTP · Docker / Render · GitHub Actions
🚀 Professional Impact
KPI | Before | After |
---|---|---|
Draft time per lead | 3 – 5 min manual writing | < 5 s end-to-end via API |
Brand-voice consistency | Operator-dependent | 100 % standardised |
Personalisation rate | 0 % | 100 % (name + trial context) |
Human scalability | 1:1 manual limit | Elastic / parallel n8n workflows |
🔧 Core Technical Highlights
Layer | Implementation Details |
---|---|
API Service | FastAPI (Python 3.12) → /generate-email , /healthz , /meta ; root redirects to Swagger /docs. |
LLM Engine | Hugging Face zephyr-7b-beta via Featherless-AI; prompt builder enforces tone + single CTA. |
Workflow Orchestration | n8n pulls new trial leads from Google Sheets, calls FastAPI, applies IF logic, then sends via SMTP. |
Data Source | Google Sheets + Apps Script REST; IDs cached to avoid resending. |
Email Delivery | Gmail SMTP (App Password) with TLS; retry & back-off node in n8n. |
Deployment | Docker / docker-compose: 2 containers (FastAPI, n8n); Render Web Service + Worker. |
CI / Uptime | GitHub Actions keep-alive pings Render every 15 min; push triggers build & tests. |
Planned | Tracking pixel, redirect analytics, OpenTelemetry spans, Celery/Rabbit queue for bulk. |
🗂️ Feature Deep-Dive
-
Lead Ingestion → Send Loop – n8n cron fetches new rows → POSTs to
/generate-email
→ sanitised copy returned → Gmail SMTP node delivers → Google Sheets updated with status. -
Guardrails & Sanitisation – Tone (“warm, motivating”), subject ≤ 55 chars, body plain-text, exactly one CTA link (
/activate?e={email}
); regex de-dupe + whitespace normalisation. -
Swagger-First QA – Live /docs enables rapid prompt tweaks;
/meta
returns Git SHA & build time. -
Containerised Dev –
docker-compose up
spins FastAPI + n8n locally; secrets via.env
file. -
Metrics Notebook – Optional Jupyter notebook analyses opens / clicks once tracking is live.
🛠️ Challenges & Solutions
Challenge | Solution |
---|---|
HF LLM latency spikes | Featherless inference endpoint + n8n queue; governor aborts after 8 s and logs lead for retry. |
Render free-plan sleep | GitHub Actions scheduled curl to /healthz ; keeps both services < 1 s cold-start. |
Multiple CTAs in LLM output | Post-process sanitiser drops extra links, enforces exactly one CTA. |
Gmail send quota | Batch size throttling & secondary service account ready; future switch to SendGrid API. |
This modular architecture delivers brand-consistent, hyper-personalised follow-up emails in under five seconds—freeing humans from repetitive drafting and laying the groundwork for tracking, analytics, and LLM chat interactions in upcoming versions.