DEV Community

Cover image for Follow-up emails that stop when the client replies: quotes and invoices in n8n
Seotow
Seotow

Posted on AI-assisted

Follow-up emails that stop when the client replies: quotes and invoices in n8n

Two emails cost freelancers more money than any other: the follow-up on a quote nobody answered, and the reminder about an invoice nobody paid. Both are easy to forget and awkward to write, so they don't get sent.

I built both in n8n with a Google Sheet and Gmail, and there's no AI model anywhere in it. This post walks through the parts that took the most thought. They apply to any "send a sequence until someone answers" workflow.

The sheet is the state

Each quote or invoice is one row. Besides the obvious columns (client, email, amount, date, status), two columns belong to the workflow:

Column Written by Purpose
LastStage workflow the last email this row received
LastSentAt workflow when it was sent

After every email, an update node writes both back, matching on the row's ID. Run the workflow three times in one morning and nobody gets a second copy, because the next run sees the stage already went out.

You could keep this state inside n8n instead (workflow static data), but then the sheet and the workflow can disagree the moment someone edits a row by hand. With the state in the sheet, what you see is what the workflow sees, and you can reset a row by clearing two cells.

Stages, not schedules

The tempting design is "wait 3 days, send, wait 4 days, send". In n8n that means long-running executions, and it breaks when you add a row that's already two weeks old.

Instead, one scheduled run each weekday looks at every open row and works out where it should be:

const STAGES = [
  { key: 'check-in',  from: 3 },
  { key: 'questions', from: 7 },
  { key: 'nudge',     from: 14 },
  { key: 'closing',   from: 30 },
];

const age = daysSince(row.SentDate);
let idx = -1;
STAGES.forEach((s, i) => { if (age >= s.from) idx = i; });

const lastIdx = STAGES.findIndex((s) => s.key === row.LastStage);
if (idx <= lastIdx) continue;            // already sent this one
if (daysSince(row.LastSentAt) < 3) continue;   // don't pile on
Enter fullscreen mode Exit fullscreen mode

A row only ever gets the latest stage it has reached. Add a quote that went out 16 days ago and it gets the 14-day email, not all three earlier ones in a burst.

Stop when they write back

This is the part most templates skip, and it's the one clients notice. Nothing reads worse than "just following up!" the morning after someone explained the delay.

A second workflow polls Gmail once an hour with the query in:inbox -from:me. For each new message it takes the sender's address and looks for an open row that has already had at least one email:

const mail = bySender[row.ClientEmail.trim().toLowerCase()];
if (row.Status === 'Open' && row.LastStage && mail) {
  // set Status to Paused, note the subject, tell me
}
Enter fullscreen mode Exit fullscreen mode

Paused rows get nothing until a person sets them back to Open. Matching on the address alone is a real limitation: a reply from a colleague at the same company won't match. I decided that's better than guessing from the domain and pausing the wrong client.

Polling hourly rather than every few minutes matters on n8n Cloud, where executions are counted. Hourly is at most 24 a day.

Draft mode first

Every workflow starts with a Settings node, and one setting is mode, which starts as draft. In draft mode the Gmail node creates drafts instead of sending, but the sheet is still updated. For the first week you open Drafts each morning, read what it wrote, and press send yourself. When the wording sounds like you, you switch to send.

Things that bit me

  • Dates from Google Sheets come back as serial numbers (46000) unless the column is formatted as plain text. The date parser handles both, plus yyyy-mm-dd and slash dates in either order.
  • HTML email in Gmail. The Monday summary is an HTML email. A font stack written as font-family:Georgia,"Times New Roman",serif inside a style="..." attribute closes the attribute early. Chrome rendered it fine, Gmail silently dropped every style after it. Use single quotes inside inline styles.
  • Reminders to clients stay plain text. HTML reminders look like a billing system. Plain text from your own address reads like you wrote it.

The two kits

I packaged both as n8n kits with sample sheets and a setup guide. I'm the seller, so weigh that accordingly:

If you'd rather build it yourself, everything above is enough to do it. Questions about the logic are welcome in the comments.

Top comments (5)

Collapse
 
hayrullahkar profile image
Hayrullah Kar •

The rule that a row only ever gets the latest stage it has reached is a nice touch. It makes back-dated rows safe to add. I see one gap in the reply check: it only pauses rows where LastStage is already set. The original quote is sent by hand, so if the client answers that email on day one with a question, the row has no stage yet. It never gets paused, and the day-3 check-in still goes out. That is exactly the 'just following up' moment the post is trying to avoid. You could drop the LastStage condition and instead require the reply's date to be later than SentDate. The date check would also stop an old, unrelated email from the same address from pausing a new quote.

Collapse
 
seotow profile image
Seotow •

Thanks for reading it that closely. You're right, and it's the worst place for that gap: a question on day one is exactly when a "just checking in" email looks careless.

I took your suggestion almost as-is. The reply watcher no longer needs a LastStage. It pauses an open quote if the reply came on or after its SentDate, and an older email from the same address is ignored. If a row has no readable date, it falls back to the old rule. The invoice kit had the same gap (with IssueDate), so it got the same fix.

One trade-off I left in: if a client has two open quotes, one reply pauses both. Matching on the Gmail thread would be more precise, but the first email is sent by hand, so you'd have to paste the thread ID into the sheet. Would you go that far, or is pausing both fine in practice?

Collapse
 
hayrullahkar profile image
Hayrullah Kar •

Nice that the invoice kit got the IssueDate version of the same fix. I would keep pausing both. A paused follow-up only costs you a manual nudge later, while a thread ID field that has to be pasted by hand will get skipped on a busy day, and then the matching quietly breaks.

Collapse
 
junfengzhou01 profile image
Junfeng Zhou •

Worth filtering out auto-replies and out-of-office mails (the Auto-Submitted header or subject keywords), otherwise a vacation responder stops the follow-ups.

Collapse
 
seotow profile image
Seotow •

Good catch, thanks. You're right: one vacation responder was enough to pause the reminders for that client, which is the opposite of what you'd want.

I pushed a fix today. The reply watcher now ignores mail with an Auto-Submitted header (anything except "no"), Precedence: auto_reply or bulk, or a subject like "Out of office" or "Automatic reply".

The part I'm least sure about is the subject check. I added a few non-English versions (French, Spanish, German, Dutch, Portuguese, Italian), but if you've seen autoresponders that skip the headers and use some other wording, I'd like to add them.