Invoke AgentForce Agent
Overview
The Invoke Agentforce Agent interaction lets you send messages to an Agentforce AI agent directly from a Dynamic Component — passing context, capturing the response, and acting on it, all without leaving the page.
You need an agent before this works
This interaction connects to an existing Agentforce agent — it does not create one. You must first build and configure your agent in Salesforce Agentforce Studio. Once it's ready, come back here to wire it into your component.
How it Works
When a user triggers the interaction (e.g., by clicking a button), your component communicates with the agent and optionally captures the response. Here's the full sequence:
The only required steps are the user action and the agent invocation. Capturing the response, passing parameters, and post-execution actions are all optional — add them when your use case needs them.
Configuration
Four settings control how the interaction behaves. The first two are required; the rest are optional.
User Message (Required)
The prompt you're sending to the agent — the instruction that tells it what to do. This can be static text, dynamic using merge syntax, or a combination of both. Merge syntax is the key to making messages context-aware: wrap any variable or component attribute in {! } to inject its live value into the message at runtime.
Static
"Summarize this account"
Merge Syntax
"Summarize account {!Datatable1.selectedRowsKeyValue}"
Combined
"You are a sales analyst. Summarize accounts: {!Datatable1.selectedRowsKeyValue}. Include ARR, industry, and key insights."
Parameters (Optional)
Pass structured data to the agent as named key-value pairs — separate from the main user message. Use this when your agent is configured to expect specific named inputs in Agent Builder, or when you want to pass data in a structured format rather than embedding it in the message text.
Response Resource Name (Optional)
The name of a Text Variable in your component where the agent's response will be stored. Once the agent replies, its answer is automatically written to this variable — making it available to display in a text component, drive visibility rules, feed into formulas, or pass to other interactions.
Step-by-Step Example
Summarizing Selected Accounts with Agentforce
Let's build a practical example where users can select multiple accounts from a data table and get an AI-powered summary by clicking a button.

Scenario Overview
You have an Avonni Data Table displaying a list of accounts in your Dynamic Component. Users can:
Check one or more accounts in the data table
Click a "Summarize Selected" button in the table's header actions
Receive an AI-generated summary of the selected accounts from an Agentforce agent
Before You Start this tutorial
You'll need:
an agent created in Agentforce Studio
an Avonni Data Table showing Account records
row selection (checkboxes) enabled on the table
Setup Steps
Prepare Your Data Table
First, you'll set up the data table that displays your accounts and configure it to allow users to select records and trigger the agent. This creates the foundation for the interactive summarization feature.
Add the Data Table
Add an Avonni Data Table to your Dynamic Component
Configure it to display Account records
API Name: Note this (e.g.,
Datatable1) - you'll need it later to reference the selected rows
Enable Row Selection
In the data table properties, enable row selection (checkboxes)
This allows users to select multiple accounts they want to summarize
Add a Header Action Button
In the data table's Header Actions section
Add a button with a label like "Summarize Selected Accounts"
This button will trigger the agent invocation when clicked
Create a Variable to Store the Agent's Response
Before invoking the agent, you need a place to store the response it returns. This variable will capture the AI-generated summary so you can display it to users or use it elsewhere in your component.
Create a Text Variable
In your Dynamic Component resources
API Name:
agentResponse(or your preferred name)Data Type: Text
This will store the summary returned by the agent

Configure the "Invoke Agentforce Agent" Interaction
Now configure what happens when users click the "Summarize Selected Accounts" button.
Select Your Header Action Button
Click on the button you created in Step 1
Add an Interaction
In the button's properties, add a new action/interaction
Select "Invoke Agentforce Agent"
Configure the Agent Settings Fill in the following fields in the interaction configuration: Agent API Name Enter the API name of your agent from Agent Force Studio. Example:
Account_Summarizer_AgentTo find your agent's API name: Go to Agent Builder → Select your agent → Copy the API Name from the agent details
User Message: This is the prompt you're sending to the agent. Copy and paste the template below, then customize as needed:
Important: Replace Datatable1 with your actual data table's API Name.
What this does:
{!Datatable1.selectedRowsKeyValue}dynamically inserts the IDs of all accounts the user selectedThe agent receives these IDs and can query Salesforce for the full account details.
Response Resource Name
Enter: agentResponse
This is the variable name you created in Step 2. The agent's summary will be stored here.

Display the Agent's Response
Now that the agent interaction is configured and will store its response in the agentResponse variable, you need to show this summary to users. We'll add a component that displays the agent's response and only appears after the agent has returned results.
Add a Display Component
Add a component to show the summary (e.g., Profile Card, Display Text, or Rich Text component)
Place it in a visible location on your Dynamic Component canvas
Configure the Component Content
In the component's properties, find the field for displaying text content
Set the value to
{!agentResponse}This will display whatever the agent returns
Set Component Visibility (Optional but recommended)
Select your display component
Find Set Component Visibility in the properties panel
Create a condition so the component only appears when there's a response to show:
What this does: The component stays hidden until the agent returns a response. Once agentResponse contains data, the component automatically appears with the summary.
What you've accomplished: Users will now see the AI-generated summary appear on screen when they click the "Summarize Selected Accounts" button. The summary component remains hidden until there's actually content to display, keeping your interface clean
Things to keep in mind
Merge syntax
Use {!variableName} anywhere in the User Message to inject live component data. Always test with real data to confirm the merge resolves correctly
Parameter names
Must exactly match the input variable names defined in your agent's Agent Builder configuration — case-sensitive
Response timing
Agent calls can take a few seconds. Add a loading indicator or informative message so users know processing is happening
Error handling
Configure an On Error action to show a toast or message if the agent invocation fails — don't leave users with a silent failure
Agent permissions
Ensure your agent has the necessary topics, actions, and Salesforce permissions to handle the request you're sending
No response resource
If you skip the Response Resource field, the agent still runs — but the response is discarded. Only skip it for fire-and-forget scenarios where you don't need to show the output
Last updated
Was this helpful?
