Skip to content

feat: automated outreach lifecycle, Gmail API, DM queue, follow-up cron#2

Merged
0xjitsu merged 2 commits into
mainfrom
feat/outreach-automation
Mar 23, 2026
Merged

feat: automated outreach lifecycle, Gmail API, DM queue, follow-up cron#2
0xjitsu merged 2 commits into
mainfrom
feat/outreach-automation

Conversation

@0xjitsu

@0xjitsu 0xjitsu commented Mar 23, 2026

Copy link
Copy Markdown
Owner

Summary

  • Outreach Lifecycle State Machine (outreach-lifecycle.ts): Centralized module with 6 events (draft_created, initial_sent, follow_up_1_sent, follow_up_2_sent, reply_detected, sequence_complete) driving automatic stage, dm_status, and next_follow_up transitions
  • Gmail API Integration: OAuth flow, server-side email sending via sendEmailViaAPI(), auto token refresh, reply detection — replaces mailto: links
  • DM Focus Mode: One-at-a-time DM sending workflow with editable textarea, progress bar, rate limit badges, and confirm-before-sent dialog
  • Follow-Up Cron (/api/cron/follow-ups): Daily at 9am UTC via Vercel Cron — checks for replies, auto-completes stale sequences, generates follow-up drafts, auto-sends emails if Gmail connected
  • Playwright DM Automator (scout/dm-automator.ts): Local script for Instagram/TikTok DMs using persistent browser session with human-in-the-loop
  • Rate limiter wired in: Token bucket + circuit breaker integrated into send endpoint

New files

  • src/lib/outreach-lifecycle.ts — status state machine
  • src/app/api/auth/gmail/route.ts + callback/route.ts — Gmail OAuth
  • src/app/api/outreach/send/route.ts — server-side email send
  • src/app/api/outreach/check-rate/route.ts — rate limit status
  • src/app/api/cron/follow-ups/route.ts — daily follow-up cron
  • packages/db/migrations/002_outreach_automation.sql — new columns + indexes
  • scout/dm-automator.ts — Playwright DM automation script

Modified files

  • src/app/api/outreach/approve/route.ts — uses lifecycle module instead of hardcoded status
  • src/app/api/outreach/launch/route.ts — adds message_type: "cold"
  • src/lib/gmail.ts — rewritten with sendEmailViaAPI(), token refresh, reply detection
  • src/components/draft-card.tsx — Gmail API send + confirm dialog for DMs
  • src/components/outreach-queue.tsx — DM Focus tab with rate limits
  • src/app/(dashboard)/settings/page.tsx — Gmail connect/disconnect
  • vercel.json — cron schedule

Test plan

  • Run migration 002_outreach_automation.sql in Supabase SQL editor
  • Set CRON_SECRET and GMAIL_REDIRECT_URI in Vercel env vars
  • Connect Gmail in Settings → verify OAuth flow stores token
  • Launch outreach → send email draft → verify email arrives, status advances to "Contacted"
  • Open DM Focus tab → copy & open profile → confirm sent → verify dm_status advances
  • Set test creator next_follow_up to today → curl /api/cron/follow-ups → verify follow-up drafts generated
  • Install Playwright in scout/ → run dm-automator.ts --dry-run → verify queue fetching works

🤖 Generated with Claude Code

0xjitsu and others added 2 commits March 24, 2026 05:16
…queue, follow-up cron

- Add outreach lifecycle module (outreach-lifecycle.ts) centralizing all
  status transitions: draft → sent → follow-up 1/2 → completed/replied
- Integrate Gmail OAuth flow (route + callback) for server-side email sending
- Build Gmail API client with token refresh, RFC 2822 MIME encoding, reply detection
- Create /api/outreach/send endpoint with rate limiter integration
- Add DM Focus Mode to queue page: one-at-a-time workflow with editable
  message, progress bar, rate limit display per platform
- Add confirm-before-sent dialog for DMs (prevents false sent marks)
- Create follow-up cron job (daily 9am UTC via Vercel Cron) that auto-sends
  email follow-ups and queues DM follow-ups for human review
- Update settings page: Gmail now uses OAuth connect/disconnect flow
- Add DB migration 002 for follow-up tracking columns and indexes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add scout/dm-automator.ts for Instagram/TikTok DM automation via
persistent Playwright browser session. Update docs to reflect all
Phase 1-4 features (lifecycle, Gmail API, DM queue, cron).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel

vercel Bot commented Mar 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
anything-command-center Error Error Mar 23, 2026 9:22pm

@0xjitsu 0xjitsu merged commit 450cb9e into main Mar 23, 2026
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant