Address Book Update Automation
This project automates the workflow of collecting Google Form responses, maintaining an up-to-date address book, and sending personalized update emails using R and blastula.
├── helpers
│ ├── compose_update_email.R # Function to generate personalized HTML emails
│ ├── load_latest_ab.R # Function to load the most recent address book CSV
│ └── test_send.R # Function to send a test email to verify SMTP setup
├── update_ab.R # Main script: merges new responses and optionally sends emails
├── utils # Utility files
└── sheet_link.txt # Stores the URL to your Google Sheet responses
-
Import latest Google Form responses
update_ab.Rreads the URL fromutils/sheet_link.txtand imports new responses viagooglesheets4. -
Merge with existing address book The script uses
load_latest_ab()to load the most recent snapshot and combines it with new responses, keeping only the most recent entry per email address. -
Preview and compose emails
compose_update_email()generates a personalized HTML email for each recipient. A preview of the first email is always displayed before sending. -
Send emails
- Run in dry-run mode by default (
dry_run = TRUE) to simulate sending and create a log. - Switch to live mode (
dry_run = FALSE) to actually send emails using blastula and stored SMTP credentials. - Each send is logged with status and timestamp.
- Run in dry-run mode by default (
-
Save snapshots and logs
- A timestamped snapshot of the updated address book is saved.
- A timestamped send log records all simulated or actual email sends.
-
Test email functionality
test_send()allows sending a single test email to verify SMTP credentials and blastula setup.
- Install required packages
install.packages(c(
"tidyverse", "lubridate", "googlesheets4", "janitor",
"blastula", "glue", "here"
))-
Google Sheets
- Save the URL of your form responses in
utils/sheet_link.txt.
- Save the URL of your form responses in
-
Blastula credentials
- Create a credentials key (e.g.,
gmail_creds) or use environment variables for SMTP_PASSWORD. - See
test_send.Rfor an example of verifying the setup.
- Create a credentials key (e.g.,
-
Configure main script (
update_ab.R) Set the following parameters at the top of the file:form_link <- "YOUR_GOOGLE_FORM_LINK" from_email <- "YOUR_EMAIL_ADDRESS" smtp_creds_key <- "YOUR_CREDS_KEY" dry_run <- TRUE # Set FALSE to actually send
-
Run the workflow
source("update_ab.R")
- Always start with
dry_run = TRUEto ensure email formatting and recipient list are correct. - Each run produces timestamped logs and snapshots for reproducibility.
- Ensure your address book and Google Form responses maintain consistent column names.
- First names missing from responses are replaced with
"Friend"for personalization.
Carson Slater
Date Created: 11.18.2025