🔬 Detect revenue leakage with Salesforce, Google Sheets, Gemini, and Slack

⚡ 16 views · 🔬 Document Extraction & Analysis

Description

Quick overview

This workflow manually audits Closed Won Salesforce opportunities against billed amounts in Google Sheets, uses Google Gemini to analyze any revenue gap, then alerts a Slack user and writes an audit note back to the Salesforce opportunity.

How it works

  1. Starts when you run the workflow manually.
  2. Fetches up to 20 Salesforce opportunities where the stage is “Closed Won” and processes them in batches with a short delay to reduce API pressure.
  3. Looks up matching billing rows in Google Sheets and totals the billed amount for the same Deal ID, then calculates the missing revenue versus the Salesforce Amount.
  4. For deals with a positive revenue gap, sends the discrepancy details to Google Gemini to classify severity and generate a root cause, recommendation, and Salesforce-ready audit note.
  5. Parses the Gemini JSON response and builds a formatted Slack message containing the deal, gap, severity, and recommended action.
  6. Sends the Slack alert and updates the Salesforce opportunity description with the audit note and the expected, billed, and missing amounts.

Setup

  1. Add credentials for Salesforce OAuth2, Google Sheets OAuth2, Google Gemini (PaLM) API, and Slack OAuth2.
  2. In Salesforce, ensure opportunities have Amount, AccountId, StageName, and Name populated and that you want to audit only deals in the “Closed Won” stage.
  3. Update the Google Sheets document and sheet to your billing ledger, and ensure it contains columns named “Deal ID” and “Billed Amount” that match Salesforce AccountId values.
  4. In Slack, select the target user (or change the node to post to a channel) and verify the connected workspace has permission to send messages.
  5. Optionally adjust the Salesforce fetch limit, batch size, and wait duration to fit your deal volume and API limits.

Additional info

How To Customize Nodes

Add-ons (Enhancements)

Use Case Examples

  1. Detect missing invoices after deal closure
  2. Identify delays in billing processes
  3. Audit revenue discrepancies across systems
  4. Monitor high-value deals for financial gaps
  5. Automate internal financial compliance checks

There can be many additional use cases depending on business needs.

Troubleshooting Guide

IssuePossible CauseSolution
No data from SalesforceIncorrect credentials or filtersVerify OAuth connection and StageName filter
No match in Google SheetsDeal ID mismatchEnsure Deal ID matches Salesforce AccountId
AI parsing failsInvalid JSON from GeminiEnsure prompt enforces strict JSON output
Slack message not sentIncorrect user ID or permissionsVerify Slack OAuth and user ID
No output after comparisonMissing amount is zeroThis is expected behavior
Salesforce not updatedIncorrect field mappingVerify Opportunity ID and field permissions
Workflow stops during executionAPI rate limitsIncrease delay in Wait node

Need Help?

If you need help setting up or customizing this workflow, you can reach out to our n8n workflow developers at WeblineIndia.

Support includes:

Contact WeblineIndia to build or extend similar automation workflows tailored to your business needs.

đź”— Nodes Used

Google Sheets, Slack, Salesforce, Google Gemini

📥 Import

Download workflow.json and import into n8n: Workflow menu → Import from File

📖 Importing guide · 🔑 Credential setup