Nightly Clay to Smartlead lead sync with a Google Sheets audit log

Every night at 11pm, push approved leads from your Clay table into a Smartlead campaign and log every send to a shared Google Sheet.

Deterministic Code
ClaySmartleadGoogle SheetsSalesOperationsData SyncEmail Automation
PromptCreate

Build a code workflow that runs every night at 11pm on a cron trigger. The job is a deterministic pipeline that syncs approved leads from a Clay table into a Smartlead campaign and writes an audit row per lead to Google Sheets. No natural-language reasoning is needed. Every step is a known API call with structured inputs.

Build-time config the workflow should accept as inputs (set once, not per run): Clay table_id for the Ready to Send table, the name of the Clay status column and the approved value (default column Status, value Approved), the Smartlead campaign_id to push into, and the Google Sheets spreadsheet_id and tab name for the audit log.

Step 1. Call the Clay Query Tables operation against the configured table_id, filtering for the approval column equals the approved value. Iterate the returned cursor until every page is drained and collect all matching rows in memory. Preserve the Clay row id on each row so we can log it later.

Step 2. Read the audit log tab in Google Sheets and build a set of emails that have already been synced in prior runs. Use this to filter the Clay rows down to only leads whose email is not already in the sheet. This is the dedupe step and it is required so we never re-add a lead.

Step 3. Map each remaining Clay row to Smartlead's lead shape: email, first_name, last_name, company_name, and one personalization custom field carried through from Clay (make the source column name configurable, default personalization). Skip rows with a missing or invalid email.

Step 4. Chunk the mapped leads into batches of up to 400 (Smartlead's bulk import limit) and call the Smartlead Add Leads to Campaign operation once per batch, targeting the configured campaign_id.

Step 5. After each Smartlead batch completes, append one row per lead to the Google Sheets audit tab via the Append Values operation. Each row should contain: run timestamp (ISO 8601, UTC), email, smartlead_status (accepted, duplicate, or the error message Smartlead returned for that lead), and the source Clay row_id. Use one Append Values call per batch, not one per lead.

At the end of the run, emit a short structured summary: total approved rows found in Clay, total skipped because of the sheet dedupe, total sent to Smartlead, and total accepted vs rejected. Log this to the workflow run output. If any step throws a hard error (auth failure, table not found, campaign not found, sheet not writable) fail the whole run loudly so the operator sees it in the next morning's inbox and can fix the config.

Additional information

What does this prompt do?
  • Sends only leads you have marked approved in a Clay table, so you stay in control of who gets emailed.
  • Adds them to a specific Smartlead campaign in batches, ready for tomorrow's outbound sequence.
  • Writes one row per lead to a shared Google Sheet so you have a running audit trail of what got sent, when.
  • Skips anyone already in the sheet, so a lead never gets pushed to Smartlead twice.
What do I need to use this?
  • A Clay account with a table of leads that has an approval field, such as a Status column set to Approved.
  • A Smartlead account and the campaign you want new leads dropped into.
  • A Google Sheet you own or can edit, used as the audit log.
How can I customize it?
  • Change the run time. 11pm is a sensible default, but pick any hour so leads are ready before your morning send.
  • Point it at a different Clay table or a different approval column value (for example Ready or Cleared instead of Approved).
  • Swap the destination Smartlead campaign, or route different lead segments into different campaigns.
  • Add or remove fields on the audit row, such as job title, LinkedIn URL, or the person who approved the lead.

Frequently asked questions

Will this send the same lead to Smartlead twice if I re-approve it?
No. Before pushing anything, the workflow reads the Google Sheet audit log and skips any lead whose email already appears there. Re-approving a row in Clay will not cause a duplicate send.
What if I have hundreds or thousands of approved leads on a given night?
The workflow walks through your Clay table in pages so no leads get missed, and it hands them to Smartlead in batches of up to 400 leads at a time, which is Smartlead's bulk import limit.
Do my teammates need to keep approving leads in Clay the way they do today?
Yes, and that is the point. Your team keeps working in Clay's UI, flipping rows to Approved as they finish enriching them. This workflow just picks up whatever is approved at 11pm and does the boring push for you.
Can I run it more than once a day, or on-demand?
Yes. You can change the schedule to run every few hours, once a week, or wire it up so you can trigger it manually before a big send.
What lands in the Google Sheet for each lead?
By default: the timestamp of the sync, the lead's email, whether Smartlead accepted them, and a reference back to the original Clay row. You can add or remove columns to match how your team tracks outbound.

Stop babysitting your Clay to Smartlead handoff.

Connect Clay, Smartlead and Google Sheets once, and Geni ships approved leads into your campaign every night while you sleep.