Salesforce Agentforce AI agents and autonomous automation (2025)
/plugin marketplace add JosiahSiegel/claude-plugin-marketplace/plugin install salesforce-master@claude-plugin-marketplaceThis skill inherits all available tools. When active, it can use any tool Claude has access to.
MANDATORY: Always Use Backslashes on Windows for File Paths
When using Edit or Write tools on Windows, you MUST use backslashes (\) in file paths, NOT forward slashes (/).
Examples:
D:/repos/project/file.tsxD:\repos\project\file.tsxThis applies to:
NEVER create new documentation files unless explicitly requested by the user.
Agentforce is Salesforce's enterprise AI agent platform that enables autonomous, proactive applications to execute specialized tasks for employees and customers. Agentforce agents use large language models (LLMs) with the Atlas Reasoning Engine to analyze context, reason through decisions, and take action autonomously.
Key Distinction: Agentforce represents the evolution from Einstein Copilot (conversational assistant) to autonomous agents that can complete tasks without human prompting.
The Atlas Reasoning Engine is the brain of Agentforce, enabling agents to:
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā Agentforce Agent ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¤
ā 1. Topics (what agent handles) ā
ā 2. Actions (what agent can do) ā
ā 3. Instructions (how agent behaves) ā
ā 4. Channel Integrations (where agent works) ā
ā 5. Data Sources (what agent knows) ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
Agentforce 2.0 is the digital labor platform for enterprises, enabling a limitless workforce through AI agents. Key enhancements:
Identify what the agent should accomplish:
Topics define what the agent can help with:
// Example: Service Agent Topics
Topic: Password Reset
- Intent: User wants to reset password
- Required Data: Email, Username
- Connected Action: PasswordResetFlow
Topic: Order Status
- Intent: User wants order status
- Required Data: Order Number or Email
- Connected Action: GetOrderStatus
Topic: Escalate to Human
- Intent: User needs human assistance
- Required Data: Case context
- Connected Action: CreateCase + NotifyAgent
Actions are what the agent can execute. These can be:
Example Apex Action:
public class AgentActions {
@InvocableMethod(label='Get Order Status' description='Retrieves order status for customer')
public static List<OrderStatus> getOrderStatus(List<OrderRequest> requests) {
List<OrderStatus> results = new List<OrderStatus>();
for (OrderRequest req : requests) {
Order order = [SELECT Id, Status, EstimatedDelivery__c
FROM Order
WHERE OrderNumber = :req.orderNumber
LIMIT 1];
OrderStatus status = new OrderStatus();
status.orderNumber = req.orderNumber;
status.status = order.Status;
status.estimatedDelivery = order.EstimatedDelivery__c;
results.add(status);
}
return results;
}
public class OrderRequest {
@InvocableVariable(required=true)
public String orderNumber;
}
public class OrderStatus {
@InvocableVariable
public String orderNumber;
@InvocableVariable
public String status;
@InvocableVariable
public Date estimatedDelivery;
}
}
Instructions guide the agent's behavior and tone:
You are a helpful customer service agent for Acme Corp.
Personality:
- Friendly, professional, and empathetic
- Patient with customers who are frustrated
- Proactive in offering solutions
Guidelines:
- Always greet customers by name if available
- Verify customer identity before sharing account information
- Offer alternatives if the requested action cannot be completed
- Escalate to human agent for: refunds >$500, legal issues, abusive customers
- Use simple language, avoid jargon
- Provide order numbers and case numbers in responses
Security:
- Never share: passwords, credit card numbers, SSN
- Always verify identity using: email, phone, or account number
- Log all interactions for compliance
Response Format:
- Keep responses under 3 sentences when possible
- Use bullet points for multiple items
- Include next steps or call-to-action
Agentforce agents can access:
Data Cloud Integration:
// Query Data Cloud from Agentforce
public class AgentDataCloudActions {
@InvocableMethod(label='Get Customer 360 View')
public static List<Customer360> getCustomer360(List<String> customerIds) {
// Query Data Cloud for unified customer data
List<Customer360> results = new List<Customer360>();
for (String customerId : customerIds) {
// Data Cloud connector provides unified view
DataCloudConnector.QueryRequest req = new DataCloudConnector.QueryRequest();
req.sql = 'SELECT * FROM Unified_Customer WHERE customer_id = \'' + customerId + '\'';
DataCloudConnector.QueryResponse res = DataCloudConnector.query(req);
Customer360 customer = new Customer360();
customer.customerId = customerId;
customer.totalPurchases = (Decimal)res.data.get('total_purchases');
customer.preferredChannel = (String)res.data.get('preferred_channel');
customer.lifetimeValue = (Decimal)res.data.get('lifetime_value');
results.add(customer);
}
return results;
}
}
Deploy agents across multiple channels:
Capabilities:
Example Flow:
Customer: "Where is my order #12345?"
ā
Agent: Validates order number
ā
Agent: Queries Order object
ā
Agent: Retrieves tracking information
ā
Agent: "Your order #12345 shipped yesterday and will arrive Thursday.
Tracking: UPS 1Z999AA10123456784. Need anything else?"
Capabilities:
Example Flow:
Lead: "Tell me about your enterprise plan"
ā
Agent: Retrieves product information
ā
Agent: Explains features, pricing
ā
Agent: Detects buying intent
ā
Agent: "Would you like to schedule a demo with our sales team?"
ā
Agent: Creates meeting, updates lead status to "Meeting Scheduled"
Capabilities:
Capabilities:
Publish events to trigger Agentforce actions:
// Publish event when order status changes
public class OrderEventPublisher {
public static void publishOrderUpdate(Id orderId, String newStatus) {
OrderStatusChangeEvent__e event = new OrderStatusChangeEvent__e(
OrderId__c = orderId,
NewStatus__c = newStatus,
Timestamp__c = System.now()
);
EventBus.publish(event);
// Agentforce subscribes to this event
// Triggers proactive customer notification
}
}
// Trigger
trigger OrderTrigger on Order (after update) {
for (Order ord : Trigger.new) {
if (ord.Status != Trigger.oldMap.get(ord.Id).Status) {
OrderEventPublisher.publishOrderUpdate(ord.Id, ord.Status);
}
}
}
Agentforce Flow (subscribed to OrderStatusChangeEvent__e):
1. Receive event
2. Query order and customer details
3. Determine notification channel (email, SMS, push)
4. Generate personalized message using LLM
5. Send notification via preferred channel
6. Log interaction in Customer timeline
Integrate Agentforce with external AI providers:
public class AgentOpenAIIntegration {
@InvocableMethod(label='Generate Response with GPT-4')
public static List<String> generateResponse(List<AIRequest> requests) {
List<String> responses = new List<String>();
for (AIRequest req : requests) {
HttpRequest httpReq = new HttpRequest();
httpReq.setEndpoint('callout:OpenAI/v1/chat/completions');
httpReq.setMethod('POST');
httpReq.setHeader('Content-Type', 'application/json');
Map<String, Object> payload = new Map<String, Object>{
'model' => 'gpt-4',
'messages' => new List<Object>{
new Map<String, String>{
'role' => 'system',
'content' => req.systemPrompt
},
new Map<String, String>{
'role' => 'user',
'content' => req.userMessage
}
},
'temperature' => 0.7,
'max_tokens' => 500
};
httpReq.setBody(JSON.serialize(payload));
Http http = new Http();
HttpResponse httpRes = http.send(httpReq);
if (httpRes.getStatusCode() == 200) {
Map<String, Object> result = (Map<String, Object>)JSON.deserializeUntyped(httpRes.getBody());
List<Object> choices = (List<Object>)result.get('choices');
Map<String, Object> choice = (Map<String, Object>)choices[0];
Map<String, Object> message = (Map<String, Object>)choice.get('message');
responses.add((String)message.get('content'));
}
}
return responses;
}
public class AIRequest {
@InvocableVariable(required=true)
public String systemPrompt;
@InvocableVariable(required=true)
public String userMessage;
}
}
public class AgentClaudeIntegration {
@InvocableMethod(label='Generate Response with Claude')
public static List<String> generateResponse(List<AIRequest> requests) {
List<String> responses = new List<String>();
for (AIRequest req : requests) {
HttpRequest httpReq = new HttpRequest();
httpReq.setEndpoint('callout:Anthropic/v1/messages');
httpReq.setMethod('POST');
httpReq.setHeader('Content-Type', 'application/json');
httpReq.setHeader('anthropic-version', '2023-06-01');
Map<String, Object> payload = new Map<String, Object>{
'model' => 'claude-3-5-sonnet-20241022',
'max_tokens' => 1024,
'system' => req.systemPrompt,
'messages' => new List<Object>{
new Map<String, String>{
'role' => 'user',
'content' => req.userMessage
}
}
};
httpReq.setBody(JSON.serialize(payload));
Http http = new Http();
HttpResponse httpRes = http.send(httpReq);
if (httpRes.getStatusCode() == 200) {
Map<String, Object> result = (Map<String, Object>)JSON.deserializeUntyped(httpRes.getBody());
List<Object> content = (List<Object>)result.get('content');
Map<String, Object> contentBlock = (Map<String, Object>)content[0];
responses.add((String)contentBlock.get('text'));
}
}
return responses;
}
}
Track agent effectiveness:
Custom Reporting Object:
public class AgentInteractionLogger {
public static void logInteraction(String agentName, String topic,
Boolean resolved, Decimal duration) {
AgentInteraction__c interaction = new AgentInteraction__c(
AgentName__c = agentName,
Topic__c = topic,
Resolved__c = resolved,
Duration__c = duration,
Timestamp__c = System.now()
);
insert interaction;
}
}
-- Resolution rate by agent
SELECT AgentName__c,
COUNT(Id) as TotalInteractions,
SUM(CASE WHEN Resolved__c = true THEN 1 ELSE 0 END) as Resolved,
AVG(Duration__c) as AvgDuration
FROM AgentInteraction__c
WHERE CreatedDate = LAST_N_DAYS:30
GROUP BY AgentName__c
-- Top topics requiring human escalation
SELECT Topic__c,
COUNT(Id) as Escalations
FROM AgentInteraction__c
WHERE Resolved__c = false
AND CreatedDate = LAST_N_DAYS:30
GROUP BY Topic__c
ORDER BY COUNT(Id) DESC
LIMIT 10
with sharing keywordsIMPORTANT: Einstein Copilot was retired in January 2025 and renamed to "Agentforce (Default)". It is now one of the Agentforce agents.
If you have Einstein Copilot (now Agentforce Assistant), migration path:
Einstein Copilot ā Agentforce (Default)
- Automatically migrated in January 2025
- Conversational UI remains the same
- Add autonomous triggers and workflows
- Convert Copilot Actions to Agent Actions
- Add proactive agent behaviors
- Enable multi-channel deployment (including Slack in 2.0)
Action Migration Example:
// Einstein Copilot Action (reactive)
@InvocableMethod(label='Copilot: Get Account Info')
public static List<Account> getAccountInfo(List<Id> accountIds) {
return [SELECT Id, Name, Industry FROM Account WHERE Id IN :accountIds];
}
// Agentforce Action (proactive + reactive)
@InvocableMethod(label='Agent: Monitor and Alert on Account Changes')
public static void monitorAccounts(List<Id> accountIds) {
// Not only retrieve data, but also:
// 1. Monitor for changes
// 2. Detect anomalies (sudden revenue drop)
// 3. Proactively alert account manager
// 4. Suggest next best actions
}
Agentforce represents a paradigm shift from conversational assistants to autonomous agents that can complete complex, multi-step tasks without human intervention while maintaining trust and security.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.