Quick overview
This workflow runs on a schedule to fetch new, unsynced Salesforce leads, pulls account journey activity from the Factors.ai API based on the lead’s email domain, and updates the lead in Salesforce with a formatted journey summary and sync/status fields.
How it works
- Runs on a schedule and loads the last successful run timestamp (defaulting to the last 7 days on first run).
- Retrieves Salesforce leads created since the last run that match the defined criteria (Demo Request conversion type, not converted, and not yet Factors-synced).
- Processes leads in batches and checks whether each lead has an email address.
- For leads with an email, extracts the email domain, waits briefly, and calls the Factors.ai account journey endpoint for that domain.
- Normalizes the Factors.ai response, searches the returned data for a valid email, and proceeds only when a valid email is found.
- Updates the Salesforce lead with a formatted journey/activity summary and marks the lead as Factors-synced, or writes a status to Salesforce when the lead has no email or no matching email is found.
- After all items are processed, commits the current run timestamp as the new last run time to avoid missing leads on partial failures.
Setup
- Add a Salesforce OAuth2 connection with permission to read and update Lead fields, including the custom fields used for status, sync flag, and journey summary.
- Provide a Factors.ai API token and replace the Authorization header value in the HTTP request to the Factors.ai journey endpoint.
- Ensure your Salesforce org has the referenced custom fields (for example, Factors_Synced__c, Factor_Lead_Journey_Summary__c, and Factors_Status__c) and adjust field mappings if your field API names differ.
- Review and adjust the Salesforce lead filter conditions (CreatedDate window, Conversion_type__c value, and conversion/sync flags) to match your lead process and desired sync scope.