Code & Snippets

Outreach Router — recent raise vs normal.

Standardizes a company's last funding date against today and routes the Zap to either the 'congrats on raising' or the normal intro outreach template.

Sourcing
JavaScript · 32 lines
C.1

Download

Grab the source file. Drop it into your service, set the required environment variables, and deploy.

Download outreach_router.jsJavaScript · 32 lines
C.2

How it works

The gist

Takes a company's last funding date (from Attio / PitchBook), standardizes it against today's date, and returns a router decision telling the next Zap step which outreach template to send:

  • congrats — they raised in the last ~2 months. Send the "congrats on the raise" outreach.
  • normal — otherwise. Send the standard intro email.

The flow

  1. Inputslastfundingdate (e.g. "2025-02-21") and todaydate (ISO from Zapier), via inputData in a "Run JavaScript" step.
  2. Standardize. Both strings get parsed into real Date objects so downstream math is correct regardless of whether the input had a time component.
  3. Compute the gap in months using an average-month constant (30.44 days), which is good enough for a 2-month cutoff.
  4. Return { outreach_type }. Branch the Zap on it — one path drafts the congrats note, the other drafts the standard intro.

Why this exists

Reaching out cold five days after a founder closes a round is a different conversation than reaching out cold five months later. This is the one-liner that picks the right opening for you so you stop sending generic intros to founders who just raised.

C.3

Source

Full source, exactly as shipped. The download above is byte-identical.

outreach_router.jsJavaScript
/**
 * Outreach Router — recent raise vs normal intro
 *
 * Takes a company's last funding date (from Attio / PitchBook) plus today's
 * date (auto-supplied by Zapier), standardizes both into real Date objects,
 * and returns a router decision telling the next step which outreach
 * template to send:
 *
 *   - "congrats" → they raised in the last ~2 months, send the
 *                  "congrats on the raise" outreach
 *   - "normal"   → otherwise, send the standard intro email
 *
 * Drop into a Zapier "Run JavaScript" step and branch the Zap on
 * `outreach_type`.
 */

const lastFunding = inputData.lastfundingdate; // e.g. "2025-02-21"
const todayRaw = inputData.todaydate;          // ISO format from Zapier

// Parse both dates — handle ISO with or without time component
const fundingDate = new Date(lastFunding);
const today = new Date(todayRaw);

// Calculate difference in months
const diffMs = today - fundingDate;
const diffDays = diffMs / (1000 * 60 * 60 * 24);
const diffMonths = diffDays / 30.44; // average days per month

const result = diffMonths <= 2 ? "congrats" : "normal";

return { outreach_type: result };