DEV Community

Pirate Prentice
Pirate Prentice

Posted on

n8n Salesforce Node: Automate CRM Records, Leads, and Opportunities (Free Workflow JSON)

Salesforce is the world's most-used CRM, and if you're running workflows that touch leads, contacts, accounts, or opportunities, the n8n Salesforce node can automate the tedious parts — data entry, record syncing, pipeline updates, and alert routing — without a custom API integration or an expensive middleware tool.

This guide covers everything you need to know to use the Salesforce node in n8n: what it can do, how to authenticate, common patterns, and the gotchas that will trip you up.


What the Salesforce Node Can Do

The n8n Salesforce node supports CRUD operations across the core Salesforce standard objects:

Object Operations
Lead Create, Get, Get All, Update, Delete, Add to Campaign, Convert
Contact Create, Get, Get All, Update, Delete, Add to Campaign
Account Create, Get, Get All, Update, Delete
Opportunity Create, Get, Get All, Update, Delete
Task Create, Get, Get All, Update, Delete
Case Create, Get, Get All, Update, Delete
Custom Object Create, Get, Get All, Update, Delete (via API Name)
Attachment Create, Get All, Delete
Document Get All
Flow Invoke
Search SOQL

The SOQL Search operation is the most powerful — it lets you run arbitrary Salesforce Object Query Language queries directly, giving you access to any object, field, or filter Salesforce supports.


Authentication

The Salesforce node uses OAuth2. Before anything else, you need a Connected App in Salesforce:

  1. In Salesforce, go to Setup → App Manager → New Connected App
  2. Enable OAuth Settings
  3. Set the callback URL to your n8n instance: https://your-n8n-instance/rest/oauth2-credential/callback
  4. Select OAuth scopes: Full access (full) or at minimum Manage user data via APIs (api) + Perform requests at any time (refresh_token, offline_access)
  5. Save, wait ~10 minutes for Salesforce to propagate the app
  6. Copy the Consumer Key (Client ID) and Consumer Secret

In n8n:

  1. Go to Credentials → New → Salesforce OAuth2 API
  2. Paste Consumer Key and Consumer Secret
  3. Set Environment to Production or Sandbox
  4. Click Connect my account and complete the OAuth flow

Sandbox users: set the environment to Sandbox — it uses https://test.salesforce.com for auth instead of https://login.salesforce.com.


3 Patterns Worth Building

Pattern 1: Typeform Lead → Salesforce Lead + Slack Alert

Use case: Every time someone fills out a lead form, create a Salesforce Lead record and ping the sales channel in Slack.

Workflow:

Typeform Trigger → Salesforce (Create Lead) → Slack (Send Message)
Enter fullscreen mode Exit fullscreen mode

Salesforce node config:

  • Resource: Lead
  • Operation: Create
  • Company: {{ $json.company }}
  • First Name: {{ $json.first_name }}
  • Last Name: {{ $json.last_name }}
  • Email: {{ $json.email }}
  • Lead Source: Web
  • Description: Form submission - {{ $now.toISO() }}

Slack message:

New lead: {{ $json.first_name }} {{ $json.last_name }} from {{ $json.company }} ({{ $json.email }})
Enter fullscreen mode Exit fullscreen mode

Free JSON: included in the n8n Workflow Starter Pack.


Pattern 2: Stripe Payment → Salesforce Opportunity Won

Use case: When a Stripe charge succeeds, find the Salesforce contact by email and create a Closed Won opportunity.

Workflow:

Stripe Trigger (charge.succeeded) → Salesforce SOQL (find Contact by email)
→ IF (contact found) → Salesforce (Create Opportunity) + Salesforce (Create Task: send welcome)
→ IF (not found) → Salesforce (Create Contact) → Salesforce (Create Opportunity)
Enter fullscreen mode Exit fullscreen mode

SOQL to find contact:

SELECT Id, AccountId FROM Contact WHERE Email = '{{ $json.data.object.receipt_email }}' LIMIT 1
Enter fullscreen mode Exit fullscreen mode

Opportunity config:

  • Name: {{ $json.data.object.description }} — {{ $now.format('YYYY-MM') }}
  • Stage: Closed Won
  • Close Date: {{ $today.toISO() }}
  • Amount: {{ $json.data.object.amount / 100 }}
  • Contact ID: {{ $('SOQL').item.json.Id }}

Pattern 3: Daily Pipeline Digest → Slack

Use case: Every morning at 8 AM, pull all Open opportunities closing this month and post a summary to #sales-pipeline in Slack.

Workflow:

Schedule Trigger (8 AM weekdays) → Salesforce SOQL → Code (format digest) → Slack (post)
Enter fullscreen mode Exit fullscreen mode

SOQL:

SELECT Name, Amount, StageName, CloseDate, Owner.Name 
FROM Opportunity 
WHERE StageName NOT IN ('Closed Won', 'Closed Lost') 
  AND CloseDate = THIS_MONTH
ORDER BY CloseDate ASC
Enter fullscreen mode Exit fullscreen mode

Code node (format):

const opps = $input.all();
if (opps.length === 0) return [{ json: { text: "No open opportunities closing this month." } }];

const lines = opps.map(o => {
  const opp = o.json;
  return `• ${opp.Name} — $${Number(opp.Amount || 0).toLocaleString()}${opp.StageName} — Closes ${opp.CloseDate}${opp["Owner.Name"]}`;
});

return [{ json: { text: `*Pipeline closing this month (${opps.length} deals):*\n${lines.join("\n")}` } }];
Enter fullscreen mode Exit fullscreen mode

6 Gotchas

1. Field API names ≠ field labels
Salesforce shows field labels in the UI ("Phone") but the API uses different names ("Phone" is lucky — "Lead Source" is LeadSource, "Annual Revenue" is AnnualRevenue). Use Salesforce's Object Manager → Fields to find the correct API name. The n8n node uses API names everywhere.

2. Required fields vary by org
Your Salesforce admin may have made custom fields required. The node will return a REQUIRED_FIELD_MISSING error if you skip them. Check your org's validation rules before assuming the standard fields are enough.

3. The "Convert Lead" operation doesn't auto-create an Opportunity
Convert Lead converts a Lead to a Contact (and Account) but does not create an Opportunity by default. Pass createOpportunity: true in the Additional Fields to create one in the same step.

4. API version matters
The n8n Salesforce node targets a specific Salesforce API version. If your org uses custom objects or newer API features, check that the node's version covers them. Salesforce releases 3 major API versions per year; older n8n versions may lag.

5. SOQL date literals are powerful but tricky
CloseDate = THIS_MONTH works, but CloseDate = LAST_N_DAYS:30 also works and is often more useful. Avoid passing JavaScript date strings directly into SOQL — use Salesforce date literals or ISO 8601 format (2026-07-21) without quotes for date fields, not datetime fields.

6. Sandbox vs Production API endpoints
OAuth tokens from a Sandbox credential do not work against Production, and vice versa. Keep two separate n8n credentials: one for each environment. Don't test with Production data.


Free Workflow JSON

All three patterns above are included as importable workflow JSON in the n8n Workflow Starter Pack — 25+ plug-and-play automations for common business integrations.

👉 Get the n8n Workflow Starter Pack ($29)


Need It Built For You?

If you'd rather have someone configure and test the workflow in your own n8n instance, I offer a done-for-you build service — $99 flat, one workflow, delivered within 48 hours.

👉 Book the Done-For-You Build ($99)


Summary

The Salesforce node in n8n covers the full lead-to-close lifecycle: inbound lead capture, contact/account sync, opportunity management, task logging, and pipeline reporting. The SOQL operation gives you a direct line to any Salesforce object without needing custom API code.

The main friction points are authentication setup (Connected App), field API name lookups, and org-specific validation rules. Once those are sorted, Salesforce becomes a reliable automation target.

Next: check out the n8n HubSpot Node guide for an alternative CRM integration with a simpler auth setup.

Top comments (1)

Collapse
 
pirateprentice profile image
Pirate Prentice

Are you using the n8n Salesforce node to sync leads from Typeform, create opportunities from Stripe payments, or build daily pipeline digests? Drop your workflow pattern in the comments — curious what CRM automations people are running with this integration.