Sub topic 12
Testing the agent in the conversation preview
This chapter assumes you have built an agent in Agentforce Builder with at least one topic, instructions, and a standard or custom action, such as the Apex action from the previous chapter. You should also have the Agentforce permission sets assigned to your user.
What the conversation preview does
The conversation preview is a chat panel inside Agentforce Builder. You type as a customer would, and the agent answers using your current topics, instructions, and actions. You can test before activation, so no real users see mistakes.
The preview runs actions for real. An action that updates a record will update it in your org. Test with sample data only.
Run a first test
Use the Case Status Questions topic from earlier. Try these messages in order:
- "How many open cases does Acme have?" This should select the topic and call the Get Open Case Count action.
- "What is the weather today?" This is out of scope. The agent should decline, as the topic's last instruction says.
- "How many open cases do I have?" without naming an account. The agent should ask which account you mean.
Each test checks a different part of the design: action use, scope, and missing input.
Read the plan tracer
Next to the chat, the builder shows how the agent handled each turn. Open the trace for a reply and look at these steps:
- Topic selection: which topic the agent chose, and why.
- Action selection: which action it called, and with what inputs.
- Action output: what the action returned, such as the case count.
- Final response: the text sent back to the user.
The trace shows where a problem started. A wrong answer with a correct action output points to the instructions. A missing action call points to the action description or the topic scope.
Common failures and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
| Agent picks the wrong topic | Topic descriptions overlap or are vague | Narrow each description so topics do not compete |
| Agent never calls the action | Action label or description does not match the request | Rewrite the description to say when to use it |
| Action fails with an access error | The agent user lacks access to the object or the Apex class | Check the permission sets and Apex class access for the agent user |
| Agent invents a number | Instructions do not say what to do with no result | Add an instruction such as "Do not guess when the action returns no result" |
| Old behavior persists | Changes were not saved or the preview was not reset | Save, then reset the preview and retry |
Make tests repeatable
Keep a short list of test messages with the expected topic and action for each. Rerun the whole list after every change, since an edit to one topic can alter how another is chosen. Include at least one out-of-scope message and one message with missing input.
Exercise
In the preview, the agent says "You have 0 open cases" for an account you know has five. The trace shows the Get Open Case Count action ran. Where do you look first, and why?
Show answer
Look at the action's output and inputs in the trace. The agent did call the action, so topic and action selection worked. Check which account ID was passed, and whether the agent user can see that account's cases, because with sharing limits the query to records that user can access. The response text is a lower-priority suspect.