Production-style Salesforce Agentforce agents built with Agent Script: a customer-service agent that triages, classifies, resolves, and escalates support cases end-to-end, plus a second agent demonstrating clean subagent routing.
Bridges the declarative (no-code routing) and pro-code (Apex + Flow actions) halves of Agentforce, with full CLI deployment automation and an Experience Cloud web-chat front door.
- An 8-person support team with 24-hour response times was losing customers to slow replies.
- Most inbound was repetitive (order status, policy lookups, account verification), the kind of work that doesn't need a human.
- The real opportunity was letting an agent absorb the repetitive ~60% so people focus on the complex 40% that needs judgment (disputes, damaged shipments, escalations).
- The hard part wasn't speed, it was trust: the agent had to be right on policy, scoped to current data, and traceable, or it just creates new cleanup.
- This agent uses deterministic actions for what must be correct (classification, case creation, escalation), LLM reasoning for the conversation, and a structured handoff to humans when it should step back.
Customer Service Agent (the golden path):
- Triages an inbound issue, capturing customer ID + description.
- Classifies the issue via an Apex
@InvocableMethod(IssueClassifier). - Searches the knowledge base (Flow) for a solution.
- Creates / updates support cases in Salesforce.
- Escalates unresolved cases to a specialist queue.
- Sends a satisfaction survey after resolution.
- Serves all of this through an Experience Cloud site + Embedded Messaging web-chat widget, with a human-agent fallback queue.
Local Info Agent (reference implementation): a resort concierge showing pure subagent routing (weather / events / resort hours / off-topic / ambiguous) with before_reasoning guardrails and no Apex, just clean Agent Script patterns.
Web chat (Experience Cloud + Embedded Messaging)
│
▼
┌────────────────────┐
│ agent_router │ (Agent Script)
└─────────┬──────────┘
┌──────────────┬───────────┼───────────┬──────────────┐
▼ ▼ ▼ ▼ ▼
triage classification resolution escalation closure
│ │ │ │ │
@utils.set apex://Issue flow://Search flow://Escalate flow://SendSurvey
Variables Classifier KnowledgeBase Case
│
▼
Salesforce records (Case, Contact, Survey Log)
Agent Script binds each step to a concrete action (apex://IssueClassifier, flow://FetchCustomer, flow://SearchKnowledgeBase) with conditional transitions (available when @variables.issue_type) and before_reasoning blocks that force mandatory actions before the LLM decides anything.
| Layer | Tooling |
|---|---|
| Agent definition | Agent Script (.agent, YAML-style) on Agentforce |
| Business logic | Apex invocable classes (IssueClassifier, WeatherService) |
| Automation | Flows (fetch customer, KB search, create/update/escalate case, survey) |
| Front door | Experience Cloud site + Embedded Messaging web chat |
| Deploy | Salesforce CLI (sf, API v66) + PowerShell orchestration |
| Routing | genAiPlannerBundles / genAiPromptTemplates |
agentforce-support-agent/
├── customer-service-agent-golden-path/ # Full deployable: triage, resolve, escalate
│ ├── force-app/main/default/
│ │ ├── aiAuthoringBundles/CustomerService_Agent/ # Agent Script definition (5 subagents)
│ │ ├── classes/IssueClassifier.cls(+Test) # Apex issue classification
│ │ ├── flows/ # FetchCustomer, SearchKnowledgeBase,
│ │ │ # UpdateCase, EscalateCase, Survey
│ │ ├── objects/ # ASR_Survey_Log__c + custom fields
│ │ ├── messagingChannels / EmbeddedServiceConfig / experiences/ # Web-chat front door
│ │ └── permissionsets/ # Agent runtime access
│ ├── scripts/publish-customer-service-agent.ps1 # End-to-end deploy + activate
│ ├── WEB_CHAT_GOLDEN_PATH.md # Web-chat integration guide
│ └── README.md
├── force-app/main/default/ # Local Info Agent (subagent-routing demo)
│ ├── aiAuthoringBundles/Local_Info_Agent/ # Agent Script
│ ├── genAiPlannerBundles/ genAiPromptTemplates/
│ └── classes/ (WeatherService, CurrentDate)
└── Local Info Agent Deployment Guide.md
- Deterministic where it must be correct. Issue classification, case creation, and escalation are Apex/Flow actions, not left to the model, so policy-critical steps are reliable and auditable.
before_reasoningguardrails. Mandatory actions execute before the LLM reasons, so the agent can't skip a required step or answer off-topic.- Subagent routing over a monolith. A central
agent_routerhands off to focused subagents (triage, resolution, escalation, closure), keeping each prompt tight. - Reproducible deployment. A PowerShell script sequences the deploy correctly (Apex, Flows, permission sets, authoring bundle, publish, activate), then queries
BotVersionto confirm activation, so there's no clicking through setup. - Meet users where they are. Embedded Messaging on an Experience Cloud site, with a human-fallback queue, so adoption needs no behavior change.
# From the golden-path package, authenticated to a Dev Hub / scratch or sandbox org:
sf project deploy start --source-dir force-app
.\scripts\publish-customer-service-agent.ps1 # publishes + activates the agent
# then wire Embedded Messaging per WEB_CHAT_GOLDEN_PATH.mdNote: Portfolio extract. No credentials are committed; deployment uses your own Salesforce CLI auth, and demo usernames/IDs are sandbox (
testdrive.org/agentforce.com) placeholders.