Templates

Salesforce Lead Creation from Engagement Score

A contact's engagement score crosses 75. This workflow checks they're not already qualified through another path, builds a Salesforce lead with the right rating (Warm/Hot), creates it, and pings the sales team on Slack.

10 minutes setupUpdated 2026-05-21

Overview

You likely score engagement elsewhere (opens, clicks, page visits, demo views). When a contact crosses your threshold, this workflow creates a Salesforce lead and notifies sales.

It assumes a primary path already creates leads (forms, demo requests, etc.) and tags those contacts as Qualified. This backup path covers contacts who became qualified through behavior without submitting a form. The tag check prevents duplicate leads.

The flow

The workflow loads contact details, exits if the engagement score is below 75, and exits if the contact already has the Qualified tag. Otherwise it builds a Salesforce lead payload with rating mapped from score (90+ Hot, 75-89 Warm), posts to the Salesforce REST API, and sends a Slack message with the new Lead ID.

Steps

  • JavaScript (map_contact_input): Pulls contact ID, name, email, phone, company, engagement score, and tags from the trigger payload.
  • JavaScript (check_engagement_threshold): Compares the score against the threshold (75). Adjust here if you want a different cutoff.
  • Switch (switch_1): Below threshold exits. Above threshold continues.
  • JavaScript (check_qualified_tag): Looks for qualified (case-insensitive) in the tags array.
  • Switch (switch_2): Already qualified exits. Otherwise continues to create.
  • JavaScript (build_salesforce_lead_payload): Maps engagement score to Salesforce Rating (Hot/Warm/Cold) and assembles the Lead object.
  • HTTP (http_1): POSTs the lead to Salesforce with a retry-3x error policy for transient API failures.
  • JavaScript (tag_contact_as_lead_created): Reads the new Lead ID from the response and prepares the Slack message.
  • Slack (slack_messaging_1): Optional notification to the sales channel.

Why the gates are ordered this way

Score is checked first because it is a fast in-memory filter. Contacts below threshold exit before tag checks run. In production you may replace the tag read with a Salesforce lookup for stronger deduplication.

Keep the retry policy on the Salesforce step. Transient 500 responses are common enough that a single attempt can miss leads over time.

Setup

  1. Set salesforce_instance_url in workflow variables (your Salesforce instance, e.g. https://yourorg.my.salesforce.com).
  2. Add salesforce_access_token to secrets. For OAuth, refresh on a schedule or add a token refresh sub-flow.
  3. Connect Slack and update slack_messaging_1 to your sales channel.
  4. Trigger from your engagement-scoring system when a contact score updates. Payload needs contactId, email, firstName, lastName, company, phone, engagementScore, and tags.

Access tokens

The Salesforce token in this workflow is a static secret, which is fine for testing. In production, refresh before create calls because access tokens expire, often within a couple of hours. Use a username-password OAuth pre-step or a connected app with a refresh token.

Adapt this template in Unmeshed

Start from the sequence above, then connect your APIs, approvals, decision logic, and notifications as durable workflow steps.