Sub topic 12
Testing in Flow Builder and in the agent preview
This chapter assumes you can build an autolaunched flow, know what input and output variables are, and have already added the flow to a topic in Agent Builder. You will test the action in two places. Flow Builder shows whether the logic works. The agent preview shows whether the agent uses the action correctly.
Why you test in two places
A flow-based action can fail in two separate ways. The flow can return the wrong data. Or the flow can be correct, but the agent never calls it, calls it with the wrong input, or reads the output badly. Flow Builder only catches the first kind of failure. The agent preview catches the second.
Test the flow first. If you test through the agent first, you cannot tell whether a bad answer came from the flow or from the agent's reasoning.
Testing in Flow Builder
Open the flow and select Debug. Flow Builder asks for values for each input variable. For the Get_Case_Status flow, enter a real case number in caseNumber, such as 00001026. Then run the flow.
The debug panel lists each element that ran and the values it used. At the end, check the output variable. Here caseStatus should hold the case status.
Run at least these cases:
- A valid input that matches one record.
- An input that matches no record.
- An empty input.
- An input with extra spaces or the wrong case.
The second and third cases test your fault paths and your "no case found" message. If caseStatus comes back empty, the agent has nothing to tell the customer. Fix that in the flow.
Two debug options matter for actions:
- Run flow as another user. Debug runs with your own permissions by default. If the action will run as someone else, such as the agent's running user, test as that user. Otherwise a record you can see might be hidden at run time.
- Rollback mode. This undoes data changes made during the debug run. Turn it on when the flow creates or updates records and you do not want test data left behind.
Testing in the agent preview
In Agent Builder, use the preview panel to chat with the agent. Ask a question in the words a customer would use, not the words in your action name. For example: "Where is my case 00001026 up to?"
Then check three things:
- Selection. Did the agent choose the topic and the action you expected?
- Inputs. Did it pass the right case number, or ask for it if you left it out?
- Output. Did it explain the result in plain language?
Turn on the preview's debug or trace view if your org offers one. It shows the topic chosen, the action called, and the input and output values. Compare them to your Flow Builder results. A mismatch tells you where the problem is.
Common problems and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
| Agent never calls the action | Vague action instructions or topic scope | Rewrite the instructions to say when to use it |
| Agent invents an input value | Input description or setting is unclear | Set the input to be collected from the user |
| Agent gives an empty answer | Output variable is blank on a failure path | Return a short message on every path |
| Works in debug, fails in preview | Different running user or permissions | Debug as the agent's user |
When you change a description or instruction, test again with several differently worded questions. One passing phrase does not show the action is reliable.
Exercise
Your flow returns the correct status when you debug it in Flow Builder, but the agent preview says it cannot find any case. Name two causes you would check first.
Show answer
First, check whether the agent passed the right value to caseNumber, by looking at the trace or the input the agent collected. Second, check whether the agent's running user has permission to read the Case record, since debug runs as you by default. Re-run the debug as the agent's user to confirm.