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-3xerror 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
- Set
salesforce_instance_urlin workflow variables (your Salesforce instance, e.g.https://yourorg.my.salesforce.com). - Add
salesforce_access_tokento secrets. For OAuth, refresh on a schedule or add a token refresh sub-flow. - Connect Slack and update
slack_messaging_1to your sales channel. - Trigger from your engagement-scoring system when a contact score updates. Payload needs
contactId,email,firstName,lastName,company,phone,engagementScore, andtags.
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.