AI Lab

Orchestration

n8n Workflows

n8n is the trigger and integration layer. AI Lab is the brain. Import the templates below into Docker n8n, point webhooks at your Next.js APIs, then review drafts in Approvals.

Architecture

Trigger (webhook / schedule / Gmail)
        │
        ▼
   n8n workflow  ──HTTP──►  AI Lab API  (Groq + Zod)
        │                         │
        │                         ▼
        │                   draft / extract
        │                         │
        └──────────────►  /approve  (human edit)
                                  │
                                  ▼
                           Gmail or local outbox

Importable workflows

Support ticket

n8n/workflows/support-ticket.json

Webhook → AI Lab drafts reply → pending approval → Gmail / outbox

API: POST /api/automation/support

Use when: Customer support tickets that need a human gate before send

Email automation

n8n/workflows/email-automation.json

Webhook → structured email draft → optional requireApproval

API: POST /api/automation/email

Use when: Outbound campaigns or follow-ups with Zod-validated JSON

CRM lead

n8n/workflows/crm-lead.json

Webhook → extract lead fields → save to local CRM store

API: POST /api/automation/crm

Use when: Inbound lead text that should become a CRM row

Meeting summary

n8n/workflows/meeting-summary.json

Webhook → summarize transcript → tasks list

API: POST /api/automation/meeting

Use when: Meeting notes / call transcripts

Run locally

  1. Start stack: docker compose -f n8n/docker-compose.yml up -d
  2. Open http://localhost:5678 and import a JSON from n8n/workflows/
  3. Activate the workflow. HTTP nodes read AI_LAB_BASE_URL (default: the live app https://ai-lab-alpha-five.vercel.app) and send header x-practice-key. Override with AI_LAB_BASE_URL=http://host.docker.internal:3001 to target local dev.
  4. After a support/email run, review at /approve — edit To / Subject / Body, then Approve or Reject.

Full notes: n8n/DOCKER.md and n8n/README.md in the repo.

Also in this stack

  • Redis on :6379 for RAG answer cache (same docker-compose)
  • In-app Automation API tab — test the same endpoints without n8n
  • Research agent can queue email drafts into the same approval queue