How Agentforce agents think and act
Topics decide the job, instructions shape behaviour and actions do the work. Interviewers look for clean topic design, well-described actions, solid security and a testing story.
- DesignTopics, instructions and actions.
- BuildFlow, Apex and prompt-template actions.
- GovernPermissions, testing and escalation.
Agentforce is Salesforce's platform for AI agents that work inside the CRM — answering customers, updating records and handing off to people. Interviews for Salesforce admins, developers and consultants now include it. Interviewers want you to explain how an agent decides what to do and how you would build, test and govern one.
1. What is an Agentforce agent?
An AI agent built on the Salesforce platform that understands a user's request in natural language, decides which of its permitted actions to take, runs them against Salesforce data and systems, and responds — for example, a service agent that checks an order, processes a return and creates a case. Agents can serve employees inside Salesforce or customers on channels such as web chat, messaging and email, and escalate to a human when needed.
2. What are topics, instructions and actions?
Topics group the jobs an agent can do (“Order Status”, “Returns”), each with a description the reasoning engine uses to classify requests. Instructions inside a topic give rules in plain language (“Always confirm the order number before giving status”). Actions are what the agent can actually do: standard actions, or custom ones built with Flow, Apex or prompt templates. A clear, non-overlapping topic design is the single biggest factor in agent quality.
3. How does the agent decide what to do?
The reasoning engine (Atlas) reads the request and conversation, picks the most relevant topic, then plans which actions to call and with what inputs, checks results and repeats until it can answer. It relies heavily on the names and descriptions of topics, actions and their inputs and outputs — so writing those clearly is real engineering work, not documentation.
4. How do you build a custom action with Apex?
Write an @InvocableMethod with clear labels and descriptions on the method and every @InvocableVariable; the agent uses those descriptions to know when and how to call it. Respect sharing and field-level security (with sharing, WITH USER_MODE), bulkify, and return plain-language results the agent can relay.
public with sharing class OrderStatusAction {
public class Request {
@InvocableVariable(label='Order Number' description='The order number the customer gave, for example 00012345' required=true)
public String orderNumber;
}
public class Result {
@InvocableVariable(label='Status Message' description='Plain-language order status to tell the customer')
public String message;
}
@InvocableMethod(label='Get Order Status' description='Returns the current status of an order. Use when a customer asks where their order is.')
public static List<Result> getStatus(List<Request> requests) {
Set<String> numbers = new Set<String>();
for (Request r : requests) numbers.add(r.orderNumber);
Map<String, Order> byNumber = new Map<String, Order>();
for (Order o : [SELECT OrderNumber, Status, EffectiveDate FROM Order
WHERE OrderNumber IN :numbers WITH USER_MODE]) {
byNumber.put(o.OrderNumber, o);
}
List<Result> results = new List<Result>();
for (Request r : requests) {
Result res = new Result();
Order o = byNumber.get(r.orderNumber);
res.message = o == null
? 'I could not find order ' + r.orderNumber + '. Please check the number.'
: 'Order ' + o.OrderNumber + ' is ' + o.Status + '.';
results.add(res);
}
return results;
}
}5. When would you use Flow vs Apex vs a prompt template for an action?
Flow for declarative record operations and simple logic that admins can maintain. Apex for complex logic, callouts to external systems, heavy data processing or anything needing unit tests and fine control. Prompt templates when the action's job is to generate text — a summary, an email draft, a recommendation — grounded in CRM data.
6. How do you test an Agentforce agent?
Use the agent builder's conversation preview to inspect which topic and actions were chosen and why, then build a test set of realistic utterances with expected topics, actions and outcomes and run it in bulk with the Testing Center. Re-run tests after every change to topics, instructions or actions. Unit-test Apex actions separately as usual.
7. How do you control what an agent is allowed to do?
The agent runs as a specific user, so profiles, permission sets, sharing and field-level security apply. Give it only the topics and actions it needs, write guardrail instructions, require confirmation for sensitive actions, define escalation to a human, and rely on the Einstein Trust Layer for data protection and auditing.
8. What makes a good Agentforce use case to start with?
High volume, well-defined and low risk, with data already in Salesforce: order status, appointment booking, case triage, FAQ answers grounded in knowledge articles, lead qualification. Measure resolution rate, escalations, customer satisfaction and handle time against the current process before expanding.
Remember
Key points
- Descriptions drive decisions
The reasoning engine reads your labels and descriptions.
- Non-overlapping topics
Overlap causes wrong topic selection.
- Agents respect security
They run as a user with normal permissions.
- Test in bulk
Re-run test utterances after every change.
Interview drill
Follow-up questions
What the interviewer asks after your first answer. Turn on practice mode, answer each one aloud, then reveal.
-
1 Why does an agent sometimes pick the wrong action? Intermediate
Usually vague or overlapping topic and action descriptions, or missing instructions. Rewrite descriptions to say when to use (and not use) each one, then re-test.
-
2 What is the difference between an employee agent and a service agent? Basic
Employee agents help users inside Salesforce with their own permissions; service agents talk to customers on external channels and run as a dedicated agent user with limited access.
-
3 How do you hand over to a human? Basic
Configure an escalation path (for example to an Omni-Channel queue) and instructions on when to use it, passing the conversation context so the customer does not repeat themselves.
-
4 How do you handle callouts in an agent action? Advanced
Use Apex with Named Credentials, handle timeouts and errors gracefully, and return a clear message the agent can relay. Keep long-running work asynchronous where possible.
-
5 How would you measure an agent's success after launch? Intermediate
Track containment or resolution rate, escalation rate, CSAT, average handling time and accuracy from reviewed transcripts, and compare against the human baseline.