Quick overview
This workflow pulls open Salesforce opportunities and their last-30-days activities, uses Google Gemini to predict escalation risk per deal, then flags high-risk opportunities in Salesforce and notifies a Slack user.
How it works
- Starts manually and fetches open opportunities and recent Salesforce Task activities from the last 30 days.
- Merges opportunities with their related activities and builds a per-deal context including amount, probability, type, activity list, and whether all activities are completed.
- Batches the deals and skips ones that have 100% probability and active/completed engagement, then waits briefly between remaining items to reduce API load.
- Sends each deal context to Google Gemini to classify risk (high/medium/low), identify specific risk flags, and return a one-line summary as JSON.
- Cleans and validates the Gemini response by stripping formatting, parsing JSON safely, and normalizing invalid risk levels to “unknown.”
- For deals marked as high risk, updates the Salesforce opportunity description with the risk details and sends a formatted alert message to a specified Slack user.
Setup
- Add Salesforce OAuth2 credentials and ensure the workflow has access to read Opportunities and query Tasks (and update Opportunities).
- Add a Google Gemini (PaLM) API credential and confirm the selected model ID (for example, models/gemini-2.5-flash) is available in your account.
- Add Slack OAuth2 credentials and set the target recipient (user) for the alert message.
- Review the Salesforce query for recent activities and the opportunity update field mapping to match your Salesforce schema and escalation process.
Additional info
Add-Ons & Enhancements
- Add Email Notifications for high-risk deals
- Store results in Google Sheets or a database
- Add Dashboard (Power BI or Tableau) for visualization
- Use a Scheduled Trigger for automated daily scans
- Add Medium Risk Alerts for early warnings
Use Case Examples
-
Enterprise Sales Monitoring
Identify high-risk enterprise deals before escalation.
-
Pipeline Health Tracking
Continuously monitor deal quality and engagement.
-
Sales Manager Alerts
Notify managers instantly about risky deals.
-
Customer Success Alignment
Detect delivery or stakeholder risks early.
-
Revenue Forecast Protection
Reduce chances of deal slippage or loss.
There can be many more use cases depending on how this workflow is extended.
Troubleshooting Guide
| Issue |
Possible Cause |
Solution |
| No data from Salesforce |
Incorrect credentials or permissions |
Reconnect Salesforce account and verify API access |
| AI response parsing fails |
Invalid JSON from Gemini |
Check prompt and ensure strict JSON output |
| Slack message not sent |
Incorrect Slack OAuth setup |
Re-authenticate Slack node |
| Workflow runs slow |
Large dataset |
Reduce batch size or optimize queries |
| Deals not updating |
Incorrect Opportunity ID mapping |
Verify mapping in update node |
| All deals marked unknown |
AI response format issue |
Check Clean & Validate node logic |
Need Help?
If you need assistance with setting up this workflow, customizing nodes or building advanced automation solutions, feel free to reach out.
WeblineIndia specializes in building scalable n8n workflows, AI integrations and business automation systems tailored to your needs. Whether it is enhancing this workflow or creating a completely new automation pipeline, expert help is available.