A simple Python-based lead automation system that:
- Pulls leads from Airtable
- Qualifies them using custom logic
- Sends personalized emails via Gmail API
- Prevents duplicate emails using SQLite
- Updates Airtable with a “Contacted On” date
No Zapier or Make required. Fully controlled in Python.
Leads are pulled from an Airtable table (Lead Contacts).
A local SQLite database (db.sql) stores:
- Lead ID
- Name
- Qualification status
- Email sent status
This prevents duplicate emails.
Custom logic determines whether a lead should receive an email.
Example:
def is_qualified(fields):
if fields.get("Email") and fields.get("Company"):
return True
return FalseUses the Gmail API to send personalized emails.
Subject:
{Name}, let's talk about your goals 🎉
Body:
Hi {Name},
We got your request for help with {Company} and I'd love to discuss your goals soon.
Best,
Team
Once email is successfully sent:
emailed = 1in SQLiteContacted Ondate field updated in Airtable (YYYY-MM-DD)
- Python
- Airtable API
- Gmail API
- SQLite
- Pandas (for display in Colab)
pip install airtable-python-wrapper python-dotenv pandas google-api-python-client google-auth-oauthlib google-auth-httplib2Create a .env file:
AIRTABLE_API_KEY=your_key_here
BASE_ID=your_base_id_here
⚠️ Do NOT commit.env,token.json, ordb.sqlto GitHub.
Add to .gitignore:
.env
token.json
db.sql
- Create a Google Cloud project
- Enable Gmail API
- Download OAuth credentials
- Generate
token.jsonand place it in your working directory
The script:
- Polls Airtable every 10 seconds
- Inserts new leads
- Sends emails if qualified
- Updates Airtable
- Displays status in console
- Built for Google Colab but works locally
- Uses polling (not webhooks)
- Designed as a simple automation demo
- Can be extended into a full CRM automation system
Never expose:
- Airtable API key
- Gmail
token.json .envfile