Sub topic 2
Action types and why you would choose Flow
This chapter assumes you know the Salesforce data model, have used Flow Builder, and understand how agents, topics, and actions relate. It covers the action types you can add to a topic and the criteria for choosing Flow over the others.
The action types you can choose from
An action is a unit of work the agent can call from a topic. Agent Builder lets you base an action on several kinds of backing logic:
| Type | What it runs | Typical use |
|---|---|---|
| Standard action | A prebuilt capability from Salesforce | Common tasks such as summarizing a record or drafting an email |
| Flow | An autolaunched flow you build | Reading or updating records with admin-built logic |
| Apex | An invocable Apex method | Complex logic, loops over large data, custom calculations |
| Prompt template | A prompt sent to a language model | Generating or transforming text using record data |
| External service | A call to an outside API | Data that lives outside Salesforce |
Available types depend on your org's setup and release, so check Agent Builder for the current list.
What Flow offers
Flow is usually the first custom option to consider, for four reasons.
- Declarative build. Admins can create and maintain it without writing code. The same people who own the process can own the action.
- Direct data access. Get Records, Create Records, and Update Records handle most Salesforce data work with no code.
- Familiar tooling. You already have Flow Builder debugging, fault paths, and run-context settings, which later chapters rely on.
- Reuse. A flow that already exists for another process can often be wrapped as an action with little change.
Only autolaunched flows (flows with no screens) can be actions. An agent cannot show a screen to a user. It collects values in conversation and passes them to the flow as inputs.
When another type fits better
Flow is not always the right choice. Consider alternatives in these cases.
- A standard action already does the job. Rebuilding it in Flow adds maintenance without benefit.
- The logic is code-heavy. Complex parsing, bulk processing, or heavy math becomes hard to read as flow elements. Apex handles it better.
- The output is generated text. A prompt template is built for that. You can still call it from a flow later (see the chapter on combining flows with Apex, subflows, and prompt templates).
- The data is external. An external service action avoids routing the call through custom plumbing.
A decision path
Applying it to the running example
The tutorial's example action looks up a case by case number and returns its status. A standard action does not cover that lookup with your rules. The task returns data, not generated text. One Get Records element does the work, so no code is needed. That makes it a good fit for an autolaunched flow, and the next chapters build it.
Exercise
A team wants an agent action that takes an account ID and sets the account's Rating field to "Hot". Which action type do you choose, and why?
Show answer
An autolaunched flow. It is a simple record update with no generated text and no complex logic, and Update Records can do it declaratively. The agent supplies the account ID as an input. Apex would work but adds code to maintain without benefit.