
If you work in sales or run your own business, you probably have a Google Sheet somewhere that acts as your lead tracker. Leads come in from your website form, webinars, and referrals — and every morning, someone opens that sheet, figures out who’s new, and writes a personalized follow-up email to each one. For a tracker with 15–20 new leads, that’s easily 45–60 minutes of copy-paste work a day.
In this tutorial, we are going to completely automate that process using Google Workspace Studio. Every weekday morning, our agent will read the tracker, pick out only the New leads, draft a personalized email for each one using Gemini, log every draft, mark the lead as contacted so it never gets double-emailed, and post a summary to the sales team’s Chat space.
This build is also a showcase for one of Studio’s most powerful recent additions: the Repeat for each step, which lets a flow loop over Google Sheets data row by row.
So let’s get started.
What We Are Building
Here is the full flow at a glance:
- On a schedule — runs every weekday at 9:00 AM
- Get sheet contents — pulls only the rows where Status = New
- Repeat for each — loops over those rows, and for each lead:
- Ask Gemini — drafts a personalized email body
- Draft an email — creates a Gmail draft with a standardized subject
- Add a row — logs the draft to an Outreach Log tab
- Update rows — flips the lead’s Status to Contacted
- Post in a space — one summary message to Google Chat after the loop

The Setup: Your Leads Tracker
The first step in this process would be to create a Google Sheet called Leads Tracker with two tabs.
The Leads tab is the source of truth, with these columns in row 1: Lead ID, First Name, Last Name, Company, Role, Email, Source, Interest, Status, Notes, Date Added. Fill it with your leads, and make sure Status holds one of three values: New, Contacted, or Closed — Won.

The Outreach Log tab just needs headers: Timestamp, Lead ID, Name, Company, Email, Email Subject, Outcome.

Step 1: The Scheduled Trigger
Head over to studio.workspace.google.com, create a new flow, and pick the On a schedule starter. Go ahead and configure the following fields:
Frequency: Every weekday
Time: 9:00 AM (your timezone)
While building, you won’t wait for the schedule — the Test run button at the bottom of the canvas triggers the flow on demand.

Step 2: Get Sheet Contents (The Deterministic Filter)
Next, we need to get the leads that haven’t been contacted yet. Go ahead and add the Get sheet contents step. This step pulls rows from a sheet that match a condition you set.
Configure the following fields:
- Spreadsheet: Leads Tracker
- Sheet: Leads
- Column: Status (the dropdown shows the names from your header row) Value: New

Stick to a single condition here. The “Add column” option is only for multi-column filtering, and setting the value to “Any” will just dump the entire sheet.
You could theoretically skip this and just pass the whole sheet to Gemini to find the new leads, but don’t. A native filter is faster, deterministic (it won’t accidentally skip a row). Let the filter handle the data extraction, and save Gemini for what it actually needs to do: writing the email.
Step 3: Repeat for Each
Add the Repeat for each step. Before adding any substeps, we first need to tell it what to loop over.
In the step’s panel, under Select a list, click + Variables, hover over Step 2: Get sheet contents, and select Full list — Matching values. This is the list of rows that matched our Status = New condition.

Once done, go ahead and click on Add step.
With the list connected, every substep we add inside this step runs once per lead, and the values from that lead’s row are available as variables: {{First Name}}, {{Company}}, {{Email}}, and so on.
Step 4: Ask Gemini
Inside the loop, add an Ask Gemini step and set Response format to Text, since we are working with one lead at a time.
Gemini only writes the email body here. The subject line comes later, in the Gmail step. Here is the prompt:
You are writing a follow-up email on behalf of [YOUR NAME], an automation consultant who helps teams automate their work with Google Workspace Studio.
Write a short, personalized outreach email to this lead: — Name: {{First Name}} {{Last Name}} — Company: {{Company}} — Role: {{Role}} — What they’re interested in: {{Interest}} — Context notes: {{Notes}}
Rules: — 90–120 words, plain conversational English, no buzzwords, no exclamation marks. — Begin with “Hi {{First Name}},” — first name only, never the full name, and never skip the greeting. — Then open by referencing their specific interest and context — never a generic “hope you’re well.” — Include exactly one concrete idea for how Workspace Studio could solve their problem, phrased in one sentence. — End with a low-pressure ask: a 20-minute call this week or next. — Write numbers as digits (20-minute, not twenty-minute). — After the last paragraph, leave one blank line, then sign off with “[YOUR NAME]” on its own line.
Return only the email body.

The prompt is strict on purpose. My first version asked Gemini for a subject line too, and every draft came out with “Subject: …” as the first line of the body. If you want something to be consistent across every email, put it in the rules.
Step 5: Draft an Email
While you are still inside the loop, add the Gmail Draft an email step.
Configure the following fields:
- To: {{Email}}
- Subject: Workspace Studio idea for {{Company}}
- Body: the output of Step 4
The subject is one fixed template, and only the company name changes. Every draft in the campaign looks the same in your Drafts folder, and searching subject:”Workspace Studio idea” in Gmail shows you the whole run at once.

We are creating drafts here, not sending. Review a few runs first, and once you are happy with the output, switch this step to Send email.
Step 6: Add a Row
Go ahead and add the Sheets Add a row step, pointed at the Outreach Log tab. Map the columns: the run timestamp, {{Lead ID}}, the name, company, email, the subject, and the text Draft created.
(Note: the log rows won’t appear in the same order as the sheet, because the loop iterations run in parallel. That is why we log the Lead ID — you can always trace a log row back to its lead.)

Step 7: Update Rows
Right now, the flow has a problem. Nothing changes the lead’s Status, so tomorrow’s 9:00 AM run would find the same leads still marked New and draft them all over again. The Update rows step fixes that.
Add it as the last step inside the loop.
Configure the following fields:
- Spreadsheet: Leads Tracker
- Sheet: Leads
- Find rows to update — Column: Lead ID, Value: {{Lead ID}} (click the + on the field and pick the variable)
- Set new values by column — Column: Status, New value: Contacted (typed as plain text)

Two things to get right here:
- Find rows by the Lead ID, not by Status. Update rows changes every row that matches the condition. If you match on Status = New, the first loop iteration updates all your leads at once. Matching on the Lead ID variable means each iteration updates exactly one row.
- Don’t mix up the two sections. The “Find” section gets Lead ID, and the “Set” section gets Status.
Step 8: Post in a Space
Outside the loop, add the Post in a space step pointed at your sales team’s Chat space:
Lead outreach agent ran ✅ Any New leads in the Leads Tracker now have drafts in Gmail — details in the Outreach Log tab.
For the chat message we have kept the wording neutral like this. This step is outside the loop, so it runs every time — including on a morning where there are no new leads at all. A message that says “drafted follow-ups!” on a day where nothing happened is going to confuse your team.

The Test Run & Output
Never just toggle a flow to live without testing it first. For this setup, we need to do two test runs.

My tracker had 16 New leads, so I’ll use those numbers — yours will match whatever is in your sheet.
This flow touches four different places — Studio, Chat, Gmail, and the Sheet — so checking the output means visiting all four. Here is the order I follow.
- The run history in Studio
The run history panel opens on the right as the flow runs. Step 2 reports “Found 16 rows matching conditions” with a chip for the Leads Tracker, and Step 3 shows “Repeat 16 items in list.”
Here is the part I really like: you can page through the iterations (1/16, 2/16, …) and see exactly what happened for each lead. For the first iteration, that means reading the exact email Gemini wrote for Priya at Nimbus Retail Co., then “Created draft — Workspace Studio idea for Nimbus Retail Co.” for the Gmail step, “Added row to the sheet” for the log, and “1 row updated” for the status change. That “1 row updated” matters — if it ever says more than 1, your Update rows step is matching on the wrong column.
At the bottom of the loop you want 16 completed, 0 with errors, then a green Run Completed banner.

2. The Chat space
Open the Sales — Outreach space in Google Chat. The summary message from the flow should be sitting there. In a real team, this message is the signal that the morning batch is ready for review — nobody has to go check whether the automation ran.

3. The Gmail drafts
Now head to Gmail and open your Drafts folder — or search in:draft subject:”Workspace Studio idea”, which shows the whole batch in one view. You should count one draft per lead, 16 in my case, every subject following the same pattern: Workspace Studio idea for Nimbus Retail Co., Workspace Studio idea for Brightline Logistics, and so on down the list.
Open a few and actually read them. This is where you check that the personalization is real and not mail-merge filler. In my run, Priya’s draft talked about her team of 40 drowning in supplier emails and suggested smart labels — pulled straight from her Notes column.
Each one opens with “Hi Priya,” or “Hi Kwame,” — first name only, no stray “Subject:” line at the top, signed off with my name. If something reads wrong here, fix the prompt rules in Step 4 and run again.

4. The Sheet — both tabs
Back in the Leads Tracker sheet, check the Outreach Log tab first. One row per lead: timestamp, Lead ID, name, company, email, the subject, and Draft created. You’ll notice the rows are not in L-001, L-002 order — iterations finish in parallel, so they land as they complete. That is exactly why we log the Lead ID.

Then the Leads tab: all 16 processed leads now show Contacted in the Status column, the Lead IDs are untouched, and the rows that were already Contacted or Closed — Won before the run haven’t changed at all.

5. Run it again
One more test, and this is the one that proves the flow is safe to schedule: hit Test run again without changing anything in the sheet.
This time Step 2 says “No rows matched conditions,” Step 3 says “Repeat 0 items in list — The list is empty,” and the flow completes without creating a single draft. Every lead is already Contacted, so there is nobody left to email. The only thing that still fires is the Chat message — it sits outside the loop — which is why we kept its wording neutral in Step 8.

Wrapping Up
Here is what each part of this flow is doing:
- The Sheet holds the data, and the Status column tracks where each lead stands.
- Get sheet contents does the filtering, so Gemini doesn’t have to.
- Repeat for each + Ask Gemini writes one personalized email per lead.
- Update rows makes sure every lead is processed exactly once.
You set it up once, and every weekday at 9:00 AM a batch of personalized drafts is waiting for a quick review — instead of an hour of writing.
Work With Me
I help companies turn their products into developer and user content — tutorials, videos, use cases, and live trainings.
- Custom Workspace Studio agents and automation consulting
- Technical content: blogs, videos, and documentation for your product
- Live trainings and workshops for your team
👉 Website: aryanirani123.com
👉 LinkedIn: https://www.linkedin.com/in/aryanirani123/
👉 YouTube: https://www.youtube.com/@AryanIrani123
If any of that sounds useful, feel free to reach out or get on a call.
Google Workspace Studio Tutorial: Sales Lead Outreach with the “Repeat for each” Loop was originally published in Google Cloud – Community on Medium, where people are continuing the conversation by highlighting and responding to this story.
Source Credit: https://medium.com/google-cloud/google-workspace-studio-tutorial-sales-lead-outreach-with-the-repeat-for-each-loop-7cc3040b6d12?source=rss—-e52cf94d98af—4
