Case Study Automation Salesforce n8n

Portfolio Case Study · 2026

Apollo → Salesforce Lead Routing

A multi-list lead enrichment workflow that pulls prospects from Apollo.io, normalizes them to Salesforce shape, and routes each lead to the correct Salesforce Web-to-Lead endpoint by segment.

+2 Prospect
segments
0 Manual CSV
handoffs
N Configurable
Apollo lists
Lead routing, assignment logic
n8n, Apollo API, Salesforce
Business context

The problem to solve

The manual process was slowing down speed-to-lead.

The New Trade Program runs outbound prospecting into two distinct audiences: Schools, which represent educational partnership prospects, and Partnership, which represents B2B partnership prospects. Each segment has its own Apollo contact list, Salesforce assignment logic, and follow-up cadence.

The risk was bad data and delayed follow-up.

The prior workflow depended on exporting CSVs from Apollo, cleaning field names, importing with Data Loader, and manually tagging each batch. That created opportunities for mis-tagging, duplicate work, and leads sitting cold before a rep could respond.

System design

Workflow architecture

01Manual triggerStarts the controlled sync.
02List IDsConfiguration array holds every Apollo segment.
03List splitEach list runs through the same logic.
04Apollo fetchPaginated API calls retrieve contacts.
05Split contactsCode node validates and unpacks records.
06Field mapApollo fields normalize to Salesforce shape.
07SwitchRoutes by source list and segment.
08Web-to-LeadPosts into the correct Salesforce path.
The design treats list IDs as data, not code. Adding a new segment means adding one entry to the config and one branch to the Switch — not duplicating an entire workflow.
Build walkthrough

How the system works

01

Configuration as data

The List IDs node holds Apollo list IDs as a configurable array. The workflow splits that array and processes each list independently, which means one set of automation logic can support multiple lead segments without creating separate workflows for each audience.

02

Pagination without recursion

Apollo returns contacts in batches, so the workflow initializes the page counter and advances pages until Apollo returns an empty result. Because n8n does not behave like a traditional programming loop, state is carried through Set nodes in a controlled way.

03

Defensive code node

The Split Contacts code node validates the API response and context before trying to transform records. Descriptive errors make the workflow easier to debug when an upstream response changes.

const inputs = $input.all();

// Validate presence of both inputs
if (!Array.isArray(inputs[0]) || inputs[0].length === 0) {
  throw new Error('Split Contacts: no Apollo response on input 0');
}
if (!Array.isArray(inputs[1]) || inputs[1].length === 0) {
  throw new Error('Split Contacts: no Init Page context on input 1');
}

const apolloJson = inputs[0][0].json || {};
const ctx        = inputs[1][0].json || {};
04

Field mapping from Apollo to Salesforce

Apollo and Salesforce use different data shapes. Apollo fields such as organization.name and present_raw_address are mapped into the format Salesforce Web-to-Lead expects, including company, street, lead source, and custom field identifiers.

05

Switch-based routing

The Switch node looks at the original Apollo list ID and routes each lead to the correct Salesforce Web-to-Lead endpoint. By tagging upstream, the lead lands in Salesforce with the source and campaign values needed for assignment rules to do their job immediately.

Roadmap

What comes next

Scheduled sync

Replace the manual trigger with a daily 6 AM sync so refreshed Apollo lists are pushed into Salesforce automatically.

Deduplication check

Query Salesforce for an existing email match before posting, so re-running the workflow does not create duplicate leads.

Apollo webhook trigger

Trigger the workflow when a list changes so Salesforce receives new contacts within minutes rather than on a fixed schedule.

Failure notifications

Send Slack alerts with failed records attached when any lead fails to post or validate correctly.

Portfolio value

What this demonstrates

Salesforce-native administration

Web-to-Lead configuration, custom field IDs, lead source tagging, campaign tagging, assignment rule design, and the practical admin work that makes a CRM usable.

Integration depth

REST API structure, pagination, multi-list processing, field transformation, and defensive input validation beyond native Salesforce configuration.

Design judgment

Configuration-as-data, separation of concerns, upstream tagging, and choosing the simplest version that solves the actual business problem.

Cross-functional thinking

The integration design and Salesforce assignment rule design work as one system, connecting marketing operations, sales follow-up, and CRM governance.