Turn flagged Gmail into Google Tasks every morning
Every weekday at 7am, an agent reads the emails you flagged with a todo label or star, then files a clear next action into Google Tasks.
Every weekday at 7am in my local time zone (cron trigger), run an agent that turns flagged emails into Google Tasks. Process one email at a time and finish the full loop on each one before moving to the next.
Step 1. Find candidate emails. Use Gmail's List Messages with a search query that matches messages I labeled "todo" OR starred in the last 24 hours, and only those still in the inbox. A query like (label:todo OR is:starred) newer_than:1d in:inbox works. Cap the batch at 25 messages per run.
Step 2. For each message id, call Gmail's Get a Message with format=full to read sender, recipients (To and Cc), subject, date, and the plain-text body. Skip the email entirely if any of these are true: it is an automated newsletter or marketing email (List-Unsubscribe header present, or sender domain is a known bulk sender), it is a calendar invite (Content-Type includes text/calendar or subject starts with "Invitation:"), or I am only on Cc with no question or request directed at me. When you skip, do not modify labels and do not create a task.
Step 3. For each email you do not skip, decide three things by reading the email: the concrete next action I need to take, the person I owe a reply or follow-up to, and the urgency. Urgency comes from explicit dates in the email, urgent language from the sender, and the sender's importance (known client or executive vs. internal teammate). Write a short imperative task title, for example "Reply to Priya re Q3 renewal terms" or "Send updated SOW to Acme by Friday".
Step 4. Pick a due date. If the email mentions a specific deadline ("by Friday", "end of week", "before our 6/20 call"), use that date. Otherwise default to two business days from today, skipping weekends.
Step 5. Create the task with Google Tasks Create Task on the list named "Inbox actions". Set the title to the imperative title from step 3, the due date from step 4, and the notes field to a short block with: From: <sender name and email>, Subject: <original subject>, Summary: <two-sentence summary of what the email is asking for>, Link: <Gmail thread permalink in the form https://mail.google.com/mail/u/0/#inbox/<threadId>>.
Step 6. After the task is successfully created, call Gmail Modify Message Labels on the same message id to remove the "todo" label and add a "queued" label. This is the idempotency mechanism so the next morning's run will not pick the same email up again. If the "queued" label does not exist yet, create it once at the start of the run.
If any step fails for a given email (rate limit, missing list, parse error), log the message id and the error and move to the next email. Do not partially-apply labels: only swap the labels after the task is confirmed created.
At the end of the run, the agent does not need to notify me. The output I care about is the new tasks sitting in my "Inbox actions" list when I open Google Tasks at 7am.
Additional information
What does this prompt do?
- Sweeps Gmail every weekday at 7am for messages you labeled "todo" or starred in the last 24 hours.
- Decides the real next step, who you owe a reply to, and how urgent it is by reading the email itself.
- Creates a Google Tasks task on your "Inbox actions" list with a short imperative title, a smart due date, and a link back to the original email.
- Marks each email as "queued" so the same message never gets turned into two tasks.
What do I need to use this?
- A Gmail account where you flag messages with a "todo" label or by starring them.
- A Google Tasks account with an "Inbox actions" list (or any list you want tasks filed to).
- A couple of minutes during setup to let the agent connect to Gmail and Google Tasks.
How can I customize it?
- Change the time it runs, for example 6:30am, or only Monday and Thursday.
- Swap the trigger from a "todo" label to a different name like "do-this", or only act on starred emails.
- Pick a different default deadline, such as next business day instead of two days out.
- Send the task to a different list like "Today" or a specific project list.
Frequently asked questions
Will it create duplicate tasks if I leave the email flagged?
What if the email already mentions a deadline?
Does it touch newsletters or calendar invites?
Can I run this on a personal Google account?
What if my "Inbox actions" list does not exist yet?
Stop letting flagged emails pile up.
Connect Gmail and Google Tasks once, and an agent files a real next action every weekday morning.