sparklesInvoke 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.

circle-exclamation

You need an agent before this works


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:

1

User Action

The user interacts with the Avonni Component (e.g., clicks a button).

2

Agent Invocation

The "Invoke Agentforce Agent" interaction sends a message to the specified Agentforce agent.

3

Data Passing (Optional)

You can pass parameters to the agent to provide context or specific instructions.

4

Agent Processing

The agent processes the message using its configured topics, actions, and AI capabilities.

5

Response Capture (Optional)

The agent's response can be captured in a resource for use within your Dynamic Component.

6

Post-Execution Actions (Optional)

You can configure actions to occur after the agent responds (e.g., display a toast message on success or error)

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.

chevron-rightAgent API Name (Required)hashtag

The unique identifier for the Agentforce agent you want to invoke. Found in Agent Builder under your agent's details. This tells Salesforce exactly which agent should handle the request.

lightbulb

To find It

Agentforce Studio → select your agent → copy the API Name from the agent details panel.

chevron-rightUser Message (Required)hashtag

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.

Message Type

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."

chevron-rightParameters (Optional)hashtag

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.

lightbulb

Naming and Mapping Parameters

Each parameter needs a name (must match what your agent expects) and a value (a static value, a component attribute, or a resource variable).

chevron-rightResponse Resource Name (Optional)hashtag

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.

circle-exclamation

Important


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:

  1. Check one or more accounts in the data table

  2. Click a "Summarize Selected" button in the table's header actions

  3. Receive an AI-generated summary of the selected accounts from an Agentforce agent

square-check

Before You Start this tutorial

Setup Steps

1

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.

  1. 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

  2. Enable Row Selection

    • In the data table properties, enable row selection (checkboxes)

    • This allows users to select multiple accounts they want to summarize

  3. 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

2

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

3

Configure the "Invoke Agentforce Agent" Interaction

Now configure what happens when users click the "Summarize Selected Accounts" button.

  1. Select Your Header Action Button

    • Click on the button you created in Step 1

  2. Add an Interaction

    • In the button's properties, add a new action/interaction

    • Select "Invoke Agentforce Agent"

  3. 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_Agent To 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 selected

  • The 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.

4

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.

  1. 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

  2. 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

  3. 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

Topic
Guidance

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?