How to Build an AI Agent for Salesforce Service Cloud (2026)
If your support runs on Salesforce Service Cloud, an AI agent that reads a case, looks up the account, answers from your knowledge base, and either replies or escalates is the highest-leverage automation you can add. There are two ways to get there: build it against the Salesforce REST API yourself, or connect an agent platform that already speaks Service Cloud. This guide covers both honestly — the real API path with code, the production work it takes, and the faster route — so you can pick the one that fits your team.
What a Salesforce Service Cloud AI agent does
The loop is the same as any support agent, wired to Service Cloud: a new case arrives → the agent reads it and the contact's history → it calls tools (look up the account, search your knowledge base, check a policy) → it posts a reply as a case comment or feed item, or routes the case to a human queue. The trick is doing that reliably against real cases. (New to agents generally? Start with AI agents for customer service.)
Option 1: Build it against the Salesforce Service Cloud API
Salesforce has a full REST API, so you can build the agent yourself. The pieces:
- Read cases — the Salesforce REST API sObject and Query (SOQL) endpoints pull the
Case, itsCaseComment/feed history, and the relatedContactandAccount. - Reply / act — create a
CaseCommentorFeedItem, orPATCHtheCaserecord (status, owner) via the sObject REST API. - Trigger on new cases — a Platform Event, streaming subscription, or outbound message fires your endpoint when a case is created.
A reply tool against the real Salesforce REST API looks like this:
import requests
INSTANCE = "https://yourco.my.salesforce.com" # from the OAuth token response
API = f"{INSTANCE}/services/data/v60.0"
HEADERS = {"Authorization": f"Bearer {ACCESS_TOKEN}", "Content-Type": "application/json"}
def reply_to_case(case_id: str, body: str):
r = requests.post(f"{API}/sobjects/CaseComment",
json={"ParentId": case_id, "CommentBody": body, "IsPublished": True},
headers=HEADERS, timeout=10)
r.raise_for_status() # handle 401 token refresh, API-limit errors
return {"status": "sent", "id": r.json()["id"]}
Wrap that (and a get_contact, a search_knowledge) as tools in an agent loop on the model of your choice — see our from-scratch walkthrough in how to build an AI agent: from scratch vs. platform.
The production part
The API calls are the easy bit. A Service Cloud agent you'd trust also needs: a webhook/event endpoint (Platform Events or outbound messages, with signature verification and idempotency so a retried event doesn't double-reply), API-limit handling (Salesforce enforces per-org daily request limits), grounding in your Knowledge base or help center (embed the articles, keep them fresh), guardrails (escalate refunds, don't leak PII), OAuth token refresh and hosting 24/7, observability, and an eval harness over real historical cases. That's weeks of work plus upkeep — the undifferentiated infrastructure every support agent needs.
Option 2: Connect Salesforce Service Cloud via Macha
If the goal is a working agent on your Service Cloud — not a project to maintain — a platform that connects natively is far faster. Macha layers on top of Salesforce Service Cloud (it's not a Service Cloud replacement or an AppExchange app you install — it connects via OAuth and works autonomously):
- One-click connect — Macha ships a native Salesforce Service Cloud connector: authorize Salesforce and the agent can read cases and post replies, with a full set of case tools ready to use.
- Ground on your help center — add your Knowledge base or public help center as a Source so replies quote real articles.
- Any other system as a tool — Custom Tools turn your order/billing/CRM APIs into agent capabilities by describing them.
- Runs and grades — the agent runs in the cloud triggered by new cases; Agent Analytics show every run, and Studies grade it against real historical cases before it goes live.
Grounding matters as much as the connection: pointing the agent at your real Knowledge articles as a Source is what keeps replies accurate instead of invented.
Build vs. connect — for Salesforce Service Cloud
| Build on the Salesforce API | Connect Macha | |
|---|---|---|
| Read/reply to cases | You write the API client | Native connector (OAuth) |
| Trigger on new cases | You build a Platform Event listener | Handled |
| Ground on help center | You embed + host a vector store | Add it as a Source |
| Hosting, token refresh, observability | Your infrastructure | Built in |
| Evaluate before go-live | You build a harness | Studies |
| Time to a live agent | Weeks + ongoing | Same day |
So which should you build?
Build on the API if you need a fully custom runtime, have strict data-residency needs, or the agent is your product. For most Service Cloud teams who just want cases resolved, a native connector gets you a measurable agent on your real cases far faster — and you keep your model of choice. You can start free on Macha, connect Salesforce Service Cloud, and test an agent on your own cases the same day.
FAQ
Is a Salesforce Service Cloud AI agent the same as Salesforce's own Agentforce? Not necessarily. Salesforce offers built-in AI, but you can also run a model-agnostic agent on top of Service Cloud (via its API or a platform like Macha) — useful if you want a specific model, custom tools across other systems, or to grade the agent your own way.
Do I need to install an AppExchange app? No — Macha connects to Salesforce Service Cloud via OAuth and works autonomously; it's an AI layer on top of Service Cloud, not an AppExchange package you install.
Can the agent take actions, not just answer? Yes — via the Salesforce API (update case status, reassign owner, add comments) plus your own systems' APIs as tools (order lookups, refunds), with guardrails on what it can do unattended.
How do I make sure it's accurate before it replies to customers? Ground it in your Knowledge base and grade it against real historical cases first (Macha's Studies do this), start in a draft/approve mode, and widen autonomy per case type as it earns trust.
Resolve tickets automatically with AI agents
Macha's AI agents work on top of the help desk you already use — no code.
Shopify
Stripe
Slack
Notion
Google Workspace
Confluence

