Quick overview
This workflow polls Salesforce Opportunity updates, validates Closed Won deals, pulls CRM data and attached PDF files, uses OpenAI to extract contractual commitments, scores conflicts and evidence gaps, and then updates Salesforce with a PROCEED/REVIEW/BLOCK handover outcome.
How it works
- Triggers every minute when a Salesforce Opportunity is updated and fetches the full Opportunity record.
- Checks whether the Opportunity stage is exactly “Closed Won”, then initializes a handover record and sets a Salesforce handover status field to “Processing”.
- Retrieves Salesforce CRM evidence for the deal by loading Opportunity products, the related Account, and Opportunity contact roles, then packages the data as evidence.
- Finds files linked to the Opportunity in Salesforce, downloads the latest file versions, extracts text from PDFs, and classifies each document type based on keywords.
- Sends each document’s text to OpenAI to extract explicit commitments, parses the JSON output, normalizes the commitments, and builds a combined commitment registry.
- Validates commitment evidence completeness, detects potential conflicts across commitments, applies rule-based risk scoring, and builds a risk register.
- Sends the consolidated CRM evidence, document evidence, commitment registry, and risk register to OpenAI for an overall risk assessment, then calculates a final PROCEED/REVIEW/BLOCK decision.
- Updates the Salesforce Opportunity with the resulting handover status and AI risk fields and returns a final handover response containing the decision, risk summary, and identified risks.
Setup
- Add Salesforce OAuth2 credentials and ensure the integration user can read Opportunities, Accounts, OpportunityLineItems, OpportunityContactRoles, and Opportunity Files (ContentDocumentLink/ContentVersion), and can update the Opportunity fields used for handover status.
- Update the Salesforce file download base URL in the HTTP request step to match your Salesforce org domain and confirm it uses the same Salesforce credential.
- Add OpenAI (or OpenAI-compatible) credentials for both AI steps and choose a model available in your environment.
- Create or map the Salesforce custom fields referenced by the workflow (for example Handover_Status__c, AI_Deal_Risk__c, AI_Decision_Timeline__c, and AI_Next_Steps__c) to valid field types and allowed values.
- Ensure Closed Won Opportunities have an Account, products, contact roles, and readable PDF attachments (not scanned images) so the PDF text extraction and commitment parsing can succeed.