DEV Community

Saraswati Stitch
Saraswati Stitch

Posted on Edited on AI-assisted

A small Python script that finds the promises in your sent mail

"I'll send it tomorrow" is a task, but it usually lives inside an email you will never reread. In a Product Hunt thread on follow-ups people promise, Alexandr Krikun gave a rule I like: any promise with a date becomes a card the minute it's said. I wanted to see how far plain pattern matching gets with the written ones.

The script

import re
from datetime import date, timedelta

DAYS = ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"]
PROMISE = re.compile(r"\b(i'll|i will|let me)\b[^.?!\n]*", re.I)
WHEN = re.compile(r"\b(today|tomorrow|(?:by |on )?(?:" + "|".join(DAYS) + r"))\b", re.I)


def due_date(sentence, sent_on):
    m = WHEN.search(sentence)
    if not m:
        return None
    word = m.group(1).lower().split()[-1]
    if word == "today":
        return sent_on
    if word == "tomorrow":
        return sent_on + timedelta(days=1)
    ahead = (DAYS.index(word) - sent_on.weekday()) % 7
    return sent_on + timedelta(days=ahead or 7)  # "by Friday", sent on a Friday, means next week


def promises(body, sent_on):
    """(sentence, due date or None) for each promise in the text you wrote."""
    own = "\n".join(l for l in body.replace("’", "'").splitlines() if not l.lstrip().startswith(">"))
    return [(m.group(0).strip(), due_date(m.group(0), sent_on)) for m in PROMISE.finditer(own)]
Enter fullscreen mode Exit fullscreen mode

The curly apostrophe replacement matters because many mail clients and phones type one. Lines starting with > are dropped so you don't collect the other person's promises from the quoted reply.

What it prints

mail = """Thanks for the call.
I'll send the quote tomorrow.
Let me check the dates and get back to you.
I will share the file by Friday!
> I'll pay on Monday
"""
for sentence, due in promises(mail, date(2026, 12, 4)):  # a Friday
    print(due or "NO DATE", "|", sentence)
Enter fullscreen mode Exit fullscreen mode
2026-12-05 | I'll send the quote tomorrow
NO DATE | Let me check the dates and get back to you
2026-12-11 | I will share the file by Friday
Enter fullscreen mode Exit fullscreen mode

The NO DATE line is the useful one. Krikun's other rule is to give "let me check" a day in the reply itself, and this list shows you where you didn't.

Where it fails

I wrote these down as tests so I wouldn't forget them:

  • "Sending it over tomorrow." is missed, since there is no "I'll".
  • "I'll send it next week." is found but gets no date.
  • "Let me know if Friday works." is flagged as a promise, and it isn't one.

A language model would handle more of these. It would also need your mail, so decide that on purpose. Whatever finds the promises, check the real thread before chasing anyone. In the same discussion, Olia Nemirovski's agent found three "urgent" follow-ups that were already done.

How we'd wire this into a follow-up setup: automating follow-up tracking

Written with AI assistance. The code was run and tested before posting.

Top comments (0)