Case

Automated Email Campaigns with Gmail API

Email marketing pipeline using Gmail API, AI personalization (DeepSeek) and Google Sheets tracking for 5-touch prospecting campaigns — from Silvigon's commercial outreach.

active Mar 2026 filtered
Cover for Automated Email Campaigns with Gmail API

Step 01

Problem

Manual email campaigns are slow, inconsistent and don't scale. Sending personalized follow-ups to dozens of contacts takes hours and it's easy to lose track of who received what. Commercial outreach for Silvigon required a systematic approach.

Step 02

Context and constraints

Built as the email outreach engine for Silvigon, an automation and ERP company. The pipeline sends multi-touch campaigns from equipo@silvigon.com with AI-personalized content, Google Sheets contact tracking, and configurable daily limits. The system handles 500+ contacts across multiple sheets.

Role: Full pipeline developer: Gmail API integration, multi-touch campaign orchestration, DeepSeek personalization, Sheets tracking, and rate control.

Step 03

Key decisions

  • Gmail API with persistent OAuth: no dependency on paid email marketing services.
  • DeepSeek generates each campaign touch with a different angle (intro, value proposition, sector insight, case study, closing).
  • Google Sheets as contact database: each row = one contact with company, email, status, current touch, date, and block/respond flags.
  • 5 touches per contact with gaps: +0d, +4d, +6d, +7d, +7d for natural pacing across weekdays only.
  • Configurable daily limit (25/day) with randomized send spacing (2-5s) to avoid Gmail blocks.
  • Automatic response detection: scans inbox for replies and marks contacts as responded + blocked.
  • Weekend guard: campaign skips Saturday and Sunday automatically.
  • Block/unsubscribe system: contacts can be flagged as blocked (SI/empty column), stopping all future sends.
  • Error handling: individual email failures don't stop the batch; rates are tracked per session.

Step 04

Outcomes

  • Fully automated 5-touch campaigns with zero manual intervention.
  • AI personalization with different approach in each touch, generated by DeepSeek.
  • Real-time contact status tracking in Google Sheets with block/respond automation.
  • 500+ contacts managed in the database with multi-sheet organization.
  • Silvigon brand: sends from equipo@silvigon.com with company signature and branding.

Metrics

  • 25 sends/day with randomized 2-5s spacing between each email.
  • 5 touches per contact with gaps: 0, +4, +6, +7, +7 days.
  • Weekdays only: automatic weekend skip.
  • DeepSeek personalization for each campaign touchpoint (max_tokens=500).
  • Google Sheets columns A-W: company, emails, status, last contact, touch count, blocked flag.
  • Automatic reply detection and contact status update.
  • Per-contact tracking: num_contactos (0-5), bloqueado (SI/empty), estado (email_1-5, responded, bounced, discarded).
  • Apple Mail/iCloud unsubscribe handling: auto-generated cancellation requests marked as discarded.

Step 05

Learnings and next improvement

Email Campaign Automator

Automated email marketing pipeline with Gmail API, AI personalization and Google Sheets tracking.

Tech stack

  • Language: Python 3.11+
  • APIs: Gmail API (persistent OAuth), Google Sheets API
  • AI: DeepSeek for content generation (max 500 tokens per touch)
  • Control: Daily limit, randomized spacing, 5-touch cycle, weekend guard
  • Contact DB: Google Sheets (500+ entries, multi-sheet)

Campaign flow

Campaign runner → [Read sheets for pending contacts] → [DeepSeek generates email content]
    → [Gmail API sends] → [Update sheet status (touch + date)]
    → [Next day: repeat until 5 touches or contact responds]

        [Auto-detect replies] → [Mark as responded + blocked]

Touch sequence

TouchGapAngle
1Day 0Introduction + value proposition
2+4 daysSector-specific insight
3+6 daysCase study / social proof
4+7 daysFollow-up with new angle
5+7 daysFinal closing

Status management

Each contact is tracked through columns in the sheet:

  • Estado: email_1 through email_5 (campaign progress), respondido, rebotado, descartado
  • Bloqueado: SI = excluded from all future sends
  • Numero de Contactos: 0-5 (current touch count)

Response handling

The system scans the inbox for replies. When a contact responds:

  • They are marked as respondido + bloqueado=SI to stop further automated emails
  • Manual replies can be handled separately by the team

Step 06

Project visual for Automated Email Campaigns with Gmail APIProject visual for Automated Email Campaigns with Gmail API