Salesforce Agentforce opens up powerful new ways to bring AI-driven decision-making into your automation. One common and practical requirement is invoking an Agentforce Agent from a Record-Triggered Flow—especially for backend processes like case assignment, enrichment, or classification.
In this blog, we’ll walk through how and why to invoke an Agentforce Agent asynchronously from a record-triggered flow, along with a real-world Case Management example.
Why Invoke Agentforce from Record-Triggered Flows?
Record-Triggered Flows are widely used for:
Automating actions when records are created or updated
Enforcing business rules
Orchestrating backend processes without code
By integrating Agentforce Agents with record-triggered flows, you can:
- Add intelligent decision logic
- Delegate complex reasoning to agents
- Keep flows lightweight and scalable
However, there’s an important architectural consideration.
Important Point: Agentforce Must Be Invoked Asynchronously
Agentforce Agents must be invoked asynchronously when called from a Record-Triggered Flow.
Why?
Record-triggered flows often run in before-save or after-save contexts
Agentforce execution can involve:
Reasoning
Topic evaluation
Apex actions
These operations are not suitable for synchronous execution inside record transactions
Solution
Salesforce provides an Agent Action that can be called asynchronously from the flow, ensuring:
No transaction blocking
Better performance
Compliance with platform limits
Real-World Use Case: Case Assignment Using Agentforce
Scenario
A support organization wants to automatically assign Case ownership using intelligent logic when a Case is created via the Web channel.
High-Level Flow Architecture
Case is created
Record-Triggered Flow fires (After Insert)
Flow checks condition:
Case.Origin == 'Web'
Flow invokes Agentforce Agent asynchronously
Agent evaluates a topic for case assignment
Agent calls an Apex Action
Apex assigns the Case owner based on region
Step 1: Create a Record-Triggered Flow on Case
Object: Case
Trigger: When a record is created
Run: After save
Entry Condition
Origin Equals Web
This ensures the agent is only invoked for web-created cases.
Step 2: Invoke Agentforce Agent Asynchronously from Flow
Inside the flow:
Add an Agent Action
Choose Invoke Agentforce Agent (Asynchronous)
Inputs Passed to Agent
Case Number
Case Id
Region (optional, if available on Case)
This keeps the flow simple and delegates intelligence to the agent.
Step 3: Configure Agentforce Agent
Inside Agentforce, configure an agent with a clear purpose.
Example Agent Purpose
“Assign Case owner intelligently based on Case region.”
Step 4: Create a Topic for Case Assignment
Within the Agent:
Create a Topic: Case Owner Assignment
This topic handles logic related to determining the correct owner
Topic Responsibility
Understand Case context
Step 5: Call Apex Class Action from Agent
Under the topic, configure an Apex Class Action.
Apex Action Inputs
CaseNumber (String)
What the Apex Class Does
Query the Case using Case Number
Read the Case Region
Query the appropriate Queue based on region
Assign the Queue as the Case Owner
Update the Case
Example Logic (Conceptual)
If Region = APAC → Assign APAC Support Queue
If Region = EMEA → Assign EMEA Support Queue
If Region = NA → Assign NA Support Queue
This keeps complex logic out of Flow and inside reusable Apex.
Key Takeaways
Record-Triggered Flows can invoke Agentforce Agents only asynchronously
Agentforce is ideal for complex decision-making scenarios
Combining Flow + Agentforce + Apex Actions creates a powerful automation pattern
Case assignment is a perfect real-world use case for this integration
No comments:
Post a Comment