Major

Salesforce Pipeline Hygiene Agent: Beyond Flow and Apex

Flow and Apex handle the rules you can write down. A Salesforce pipeline hygiene agent reads calls, email and contracts to flag dead deals for rep review.

Jose GironUpdated
Major x Salesforce lockup for Salesforce automation with AI agents

Flow Builder, Apex and approval processes change Salesforce records on rules you can write down in advance, within governor limits. Pipeline hygiene needs judgment across call notes, emails and contracts, like deciding which stalled deals are dead. A Salesforce pipeline hygiene agent does that by calling the Salesforce REST API from outside the org and proposing changes a rep approves.

For the full Salesforce API guide, connection setup and every Salesforce use case, see More Salesforce use cases.

If you are a RevOps lead or platform owner building that agent, Major is where it should live. An agent reasons once about the workflow, then builds a deployed app for the repeatable steps: the SOQL query, the batching, the upsert, the Slack post. The app holds its own state, runs under a scoped Salesforce integration user, and logs every write. The model only handles the judgment call.

What Flow, Apex and approval processes cover

Five surfaces, and they are not interchangeable.

  • Flow Builder: declarative record-triggered, scheduled and screen flows for rules you can specify up front.
  • Apex: code inside the platform for logic Flow cannot express, such as triggers and scheduled classes.
  • Approval processes: a state machine on a record that routes it through named approvers.
  • Agentforce: Salesforce's own reasoning layer, built from subagents (called topics until the April 2026 rename) and actions.
  • External integrations: anything calling the REST API from outside, including your own service, an ETL job or an AI agent.

The first four run inside Salesforce's transaction boundary and pay its per-transaction costs. The fifth runs on your infrastructure and pays a different cost. Deciding which side of that line a piece of work belongs on is the real design decision.

Salesforce governor limits and API limits

Inside the platform, Apex and Flow share per-transaction governor limits: 100 synchronous SOQL queries and 150 DML statements per transaction. Hit them and the transaction fails. That is why bulk-heavy or cross-record logic gets awkward in Flow.

An external agent escapes those limits and meets a different set. The 24-hour API allocation is org-wide and rolling. Developer Edition gets 15,000 requests flat. Enterprise and Unlimited start at 100,000 plus per-license allocations and purchased add-ons. Separately, orgs allow 25 concurrent requests, which applies only to calls lasting 20 seconds or longer. Both are in Salesforce's platform API limits cheatsheet.

Call /services/data/v67.0/limits before anything else. It confirms auth and shows your remaining allocation in one request.

Where an AI agent over Salesforce helps

Use Flow when the logic is deterministic. "This stage plus this amount routes to this queue" is a record-triggered Flow, and an admin can maintain it. An agent earns its place where the judgment is real.

  • Opportunity triage: a Flow can flag every deal past its close date. Only a reader of call notes and email threads can tell which of those forty are dead and which are waiting on a procurement cycle that always runs three weeks.
  • Lead scoring on unstructured signal: scoring on firmographics is a formula field. Scoring on what a prospect said on a discovery call is not.
  • Pipeline reporting: reports render numbers. The weekly question is why they moved, which means correlating stage changes against activity, ownership churn and competitor mentions.
  • Account outreach prep: assembling six months of touchpoints across four systems is mechanical. Deciding what to say this week is not.

Each has the same shape: a large deterministic gathering step, one small judgment step, and a deterministic write step.

What you need to know about the Salesforce API

Authentication first. As of Spring '26, creating new connected apps is restricted by default and Salesforce directs you to external client apps. Two OAuth flows fit a server-side agent: JWT bearer and client credentials. The username-password flow is blocked by default for orgs created Summer '23 or later. Client credentials needs a designated Run As user and must POST to your My Domain token endpoint, not login.salesforce.com.

The token response carries access_token and instance_url. Use instance_url as the base for every call. After that you get sObject CRUD, SOQL at /query, and upsert by external ID, which is the idempotency primitive that stops a re-run from double-writing.

Three gotchas bite in production.

  • The sharing trap: API calls respect the sharing model. In a Private-OWD org, an under-permissioned integration user gets a partial result set with no error. The agent then reasons over truncated data and is confidently wrong.
  • Batching is easy to get backwards: /composite bundles up to 25 subrequests as one call. /composite/batch takes the same 25 and counts each separately. Same ceiling, 25 times the allocation cost.
  • Versions retire: v7 through v30 return HTTP 410, and v31 through v40 are announced for retirement in Summer '28. Pin a version and track the calendar.

Before production, run your real query as the integration user and diff the row count against the same query run as an admin. If they differ, you found the sharing trap early.

Worked example: the pipeline-hygiene agent

The question a RevOps lead asks every week is which open opportunities are quietly rotting and what should happen to each one. The agent runs at 7am on weekdays, ahead of pipeline review.

  1. Trigger: a schedule. The question is weekly, so event-driven would be wrong.
  2. Read: one SOQL query for opportunities past expected close date or with no activity in 21 days, then related records through /composite.
  3. Enrich: Gong call mentions and DocuSign contract status, keyed by account.
  4. Decide: the model reads the assembled context and rules at risk or merely slow, then drafts a next step per owner. This is the only step that needs a model.
  5. Write: upsert findings to the opportunity by external ID.
  6. Notify: post a ranked digest to Slack and route flagged deals to their owners.

Steps 1, 2, 3, 5 and 6 are identical every run. Only step 4 changes with the input.

Build the pipeline-hygiene agent on Major

Major splits that workflow along the line it already has. The deterministic five steps become an app. The judgment stays with the agent.

  • Connectors: Salesforce, Gong, DocuSign and Slack, each attached with scoped credentials rather than a shared service account.
  • The app: holds a managed database of last week's findings, per-opportunity history and the composite batching logic, so a weekly job does not eat the org's 24-hour allocation.
  • The agent: reasons once to design the workflow and builds the app. On each run it calls the app and spends model tokens only on the at-risk call and the drafted next step.
  • The trigger: a workflow on a weekday 7am schedule.
  • Governance: a dedicated Salesforce integration user on the Minimum Access - API Only Integrations profile, with object and field permissions limited to Opportunity, Account and Task. RBAC on who can edit the app, and an audit log of every upsert and Slack post.

An agent that re-reasons the whole workflow every Monday fires individual REST calls per record, burns allocation and gives a different answer each week for reasons nobody can reconstruct. A deployed app gives you the same batching, the same writes and a log to read. Reason once, run forever. Start building on Major and the five repeatable steps become a deployed app with its own database, permissions and logs.

Agentforce is Salesforce's own route to the same goal. It requires Data 360 to be provisioned and enabled, and Salesforce owns the reasoning loop and meters it per action. On Major you own the governed app the agent built.

More use cases by tool: More DocuSign use cases, More Gong use cases, More Salesforce use cases, More Slack use cases.

Start building on Major

Build a governed Salesforce pipeline-hygiene app on Major, with Gong, DocuSign and Slack attached, and let the agent spend its reasoning only on the deals that need a call.

Related articles

Frequently asked questions

What does Salesforce automation do?
Salesforce automation executes work on CRM records without manual clicks. Inside the platform, Flow Builder runs declarative record-triggered and scheduled processes, Apex runs custom code, and approval processes route records through approvers. Outside the platform, external services and AI agents call the Salesforce REST API to read, enrich, and write records on their own schedule and infrastructure.
Can you automate Salesforce without code?
Yes. Flow Builder handles record-triggered, scheduled, and screen-based processes declaratively, and approval processes route records without code. Declarative automation covers any rule you can specify in advance, such as stage changes, field updates, and task creation. It stops where judgment starts. Deciding whether a stalled deal is dead or waiting on procurement requires reading call notes and contracts, which no Flow condition expresses.
What is the difference between Salesforce automation and CRM?
The CRM is the system of record. It stores accounts, contacts, opportunities, and activity history. Automation is the layer that acts on those records: Flow, Apex, approval processes, and external API integrations that read, update, and route them. CRM holds the state. Automation changes it. You can run a CRM with no automation at all, just with more manual work.
What are Salesforce API limits?
Two limits matter most. The 24-hour allocation is org-wide and rolling: Developer Edition gets 15,000 requests flat, while Enterprise and Unlimited start at 100,000 plus per-license allocations and any purchased add-ons. Separately, orgs allow 25 concurrent requests, a ceiling that applies only to calls lasting 20 seconds or longer. Both are documented in Salesforce's platform API limits cheatsheet.
Does Agentforce require Data Cloud?
Yes. Data 360, formerly Data Cloud, must be provisioned and enabled before Agentforce works properly. Salesforce's org setup guide states that Data 360 is required for the Einstein Trust Layer to function correctly. That is a real cost of entry, and Salesforce owns the reasoning loop and meters it per action. On Major you own the governed app the agent built instead.