Step-by-Step Guide to Customizing Agentforce Response UI with Custom Lightning Types

Agentforce is good at retrieving data. What it returns by default, though, is plain text — and plain text has limits. When a sales rep asks the agent to show open opportunities, they get a block of sentences where they need a scannable, structured list.

Custom Lightning Types solve this. They give you direct control over how Agentforce renders its output in the chat panel, replacing the default text response with a Lightning Web Component you design. The agent handles the intelligence; you handle the interface.

This guide walks through a complete, working implementation. You will build an Apex class that retrieves Opportunity records, a Lightning Web Component that renders them as color-coded cards, a Custom Lightning Type that connects the two, and a Custom Agent Action that surfaces the result inside Agentforce.

By the end of this guide, you will be able to display a formatted, interactive list of Opportunities directly in the Agentforce chat panel using a custom UI you control.

The Problem with Plain Text Responses

When Agentforce returns data today, it formats it as a text response. For simple answers, that is fine. For structured data — a list of deals, a set of cases, a collection of records with multiple fields — it falls apart quickly.

A sales rep asking "show me all open opportunities" gets something like a paragraph describing each opportunity in sequence. There is no visual hierarchy, no way to spot urgency at a glance, and no differentiation between a deal closing tomorrow and one closing in six months. The information is technically correct and practically hard to use.

This is not a gap in Agentforce's reasoning — it is a gap in how the response is presented. Custom Lightning Types are Salesforce's answer to that gap. They let you override the default output renderer with a component you build, so the agent's response looks and behaves exactly as your users need it to.

How Custom Lightning Types Work

Understanding the architecture makes the implementation straightforward. There are three layers, each with a distinct job.

1. Apex — The Foundation (Backend Logic)

The Apex class is where the data comes from. It is written as an invocable method, which is what allows Agentforce to call it as an agent action. The class queries the records you need and returns them as structured wrapper objects — inner classes that define exactly which fields the agent will pass along. Each field you want to display in the UI needs to be defined here as an `@InvocableVariable`.

2. Lightning Web Component — The Face (Frontend Experience)

The LWC is what the user actually sees. It receives the data from the Apex class and renders it however you choose — cards, tables, lists, whatever fits the use case. The key requirement is that the component must declare `lightning__AgentforceOutput` as a target in its metadata file. Without that, the component is invisible to Agentforce. Data from the agent is injected directly into the component's `@api` properties.

3. Custom Lightning Type — The Bridge (Metadata)

The Custom Lightning Type is what connects the other two. It is a metadata definition that tells Agentforce: here is the data structure (from Apex), and here is the component that should render it (the LWC). In the Setup UI, you create the type, link it to your Apex wrapper class, navigate to the UI Configuration tab, and set your LWC as the Collection Renderer Override. From that point, any agent action that uses this Lightning Type as its Output Rendering will display data through your component instead of as plain text.

The relationship is clean: Apex provides the data, the Custom Lightning Type bridges the two, and the LWC presents the result. Change the LWC and the presentation changes. Change the Apex and the data changes. The type definition in the middle stays the same.

Step-by-Step Guide

In this step-by-step guide with screenshots, you'll create a complete solution that includes:

  1. Sign Up & Set Up Agentforce Developer Edition Org

  2. Create a New Employee Agent in Agentforce Builder

  3. Create an Apex class with an invocable method that retrieves Opportunity records, with optional filtering by name

  4. Create & Deploy a Lightning Web Component (LWC) with four files — HTML template, JavaScript controller, CSS, and the metadata XML — that renders opportunities as color-coded cards based on stage and close date urgency

  5. A Custom Lightning Type linked to the Apex wrapper class and configured to use the LWC as its output renderer

  6. A Custom Agent Action in Agentforce Assets, with the Custom Lightning Type set as Output Rendering

  7. The custom action added to the agent

  8. And finally test the agent to make sure that every thing is working fine.

(Code for Apex Class and LWC is provided in the course area)

The full step-by-step walkthrough with screenshots is embedded below.

Things to Watch Out For

A few things in this implementation are not obvious from the UI alone and will cost you time if you miss them.

  • The `lightning__AgentforceOutput` target is mandatory. This is what makes the LWC visible to Agentforce. If your component does not appear in the renderer picker inside the Custom Lightning Type, this is the first thing to check. You also need the corresponding `targetConfig` entry with a `value` property typed as `lightning__listType`.

  • Deploy before you configure. The LWC must be deployed to the org before it appears as a renderer option in the Custom Lightning Type setup. If the component is not showing up, verify the deployment succeeded under Setup > Lightning Components.

  • Enable "Show in Conversation" on the output. In the Custom Action configuration, the output parameter must have "Show in Conversation" checked. Without it, the agent will execute the action but the LWC will not render in the chat panel.

  • Hard refresh when switching rendering modes. Agentforce applies aggressive caching. If you change the rendering from standard to a custom LWC and the old layout keeps appearing, do a hard refresh or clear the cache before concluding something is broken.

  • Folder names are case-sensitive. The metadata folder structure requires exact casing. `lightningTypes` and `lightningDesktopGenAi` must be written exactly as shown, or deployment will fail silently.

Summary

Custom Lightning Types are one of the more powerful customisation tools available in Agentforce today, and they are underused — partly because the documentation is sparse, and partly because the implementation touches three different layers (Apex, LWC, metadata) in a way that is not immediately obvious.

The pattern itself is clean once you understand it. Define the data in Apex, build the UI in LWC, connect the two with a Custom Lightning Type, and wire it to an agent action. Once you have built it once, you can apply the same pattern to any object — Cases, Contacts, Contracts, custom objects.

The example in this guide uses Opportunities, but the architecture is identical regardless of what data you are rendering.


Agentforce Advisory, Training & Implementation Services

If you’d like help going deeper with Agentforce beyond this guide, I offer the following:

  • Self-Paced Training – #Mastering Agentforce

    A structured, hands-on course covering Agentforce concepts, Prompt Templates, Agents, Actions, and real-world implementation patterns.

  • Live Online & Onsite Agentforce Training

    Instructor-led training for Salesforce teams, partners, and customer organizations, tailored to real use cases and practical scenarios.

  • Agentforce Advisory & Implementation Services

    Strategic advisory and hands-on implementation support to help you design, build, and scale Agentforce solutions with confidence.

For training, advisory, or implementation discussions, please reach out via the Contact page, where you can submit a form or schedule a conversation.


References & Useful URLs



Got a takeaway? I’d love to hear it—leave a comment 👇