Build a Custom Lightning Type for Agentforce
Learning Objectives
After completing this unit, you’ll be able to:
- Create an Apex-based Lightning type using existing Apex classes.
- Assign a custom renderer component to your Lightning type.
- Configure field mappings between schema and components.
- Enhance existing agent actions with custom Lightning type output rendering.
- Test and verify your Lightning type integration.
Scenario
Coral Cloud Resorts has a Check Weather agent action that retrieves weather information for guests. The action works well in the current experience, but the weather information is displayed using default text formatting with no visual indicators.

The Coral Cloud team wants to enhance the guest experience with branded visuals for weather data. After adding a custom Lightning type, the weather data displays as a colorful card with display sections and clear labels.

To accomplish Coral Cloud’s request, you’ll create a custom Lightning type that uses the existing DailyWeatherApex class and add a custom renderer to transform the weather output into a rich, visual experience.
Sign Up for a Custom Playground with Agentforce.
To complete this badge, you need a special limited-time custom playground that contains Agentforce and our sample data.
- Select Create Playground, then select Yes, Create Playground.
- Your new org is automatically attached to your Trailhead account.
- Make note of your org’s expiration date and complete this badge before then.
- Select Launch to open the playground.
Create the Apex-Based Lightning Type
You’ll create a Lightning type that uses the existing DailyWeather Apex class, which defines weather data structure.
- Click Setup
and select Setup.
- In the Quick Find box, enter
Lightning Types, and then select Lightning Types.
- Click New Lightning Type.
- Enter these details.
- Label:
Weather Display Enhanced - API Name:
Weather_Display_Enhanced - Description:
Apex-based type for displaying Coral Cloud weather with custom branded UI
- Label:
- Click Next.
- Select Apex as the schema definition method.
- In the Search Apex Class field, start typing
DailyWeather, then select it from the dropdown when it appears.
- Click Create.
Configure the Custom Renderer Component and Field Mappings
Now configure the renderer to display weather data with custom visuals and map the fields.
- Open your Weather Display Enhanced Lightning type if it's not already open.
- Select the UI Configuration tab.
- Confirm Agentforce (Lightning Experience) is selected in the Channel dropdown.
- Select the Renderer tab.
- In the Renderer Override section, click Change.
- In the Select an Output Component window, select enhancedWeatherWidget from the list.
- In the LWC Field Mapping section, verify these component fields are mapped to your Apex class fields. Note: Because the field names in the Apex class match the field names in the LWC component, automatic field mapping should handle all connections. If any field isn’t automatically mapped, you can manually map it in this same window.
minTemperatureC = minTemperatureCminTemperatureF = minTemperatureFmaxTemperatureC = maxTemperatureCmaxTemperatureF = maxTemperatureFcondition = conditionwindSpeed = windSpeedwindDirection = windDirectionhumidity = humidity
- Click Done.
- Click Save.
Confirm that the Renderer Override section now shows enhancedWeatherWidget as the selected component, and that all eight fields were properly mapped with no warnings.
Enhance the Check Weather Agent Action Output
Now integrate your custom Lightning type into the Check Weather action through Agentforce Builder.
- From the App Launcher
, search for and select Agentforce Studio
.
- In the agents list, click Agent Customization.
- Click New Version.
- Under Subagents, select Answer Weather Questions.
- Select the Check Weather action.
- Switch to Script mode
using the toggle at the top of the canvas.
- Locate the
advancedWeatherDetailsoutput parameter.
- Replace the existing value of the
complex_data_type_nameproperty withc__Weather_Display_Enhanced. Custom Lightning types use thec__namespace prefix.
- Click Save.
- Click Commit Version.
- Click Commit.
- Click Activate.
- Click Activate again.
Confirm the complex_data_type_name property shows c__Weather_Display_Enhanced. This ensures your custom renderer with branded visuals will display weather data.
Test Your Enhanced Weather Display
Time to see your custom Lightning type in action! You’re already in Agentforce Builder from the previous steps.
- Still in Agentforce Builder, click Preview to enter Live Test Mode.
- In the Describe your task or ask a question box, enter
Check the weather today. - Observe how the weather information displays using your custom renderer with visual indicators.
Verify the following.
- Weather data displays with your custom branded UI.
- Temperature ranges show with visual indicators.
- The display is more engaging than plain text.
Congratulations! You’ve successfully built an Apex-based Lightning type, configured custom UI components, and integrated it with an Agentforce Employee agent in Lightning Experience. You’re now ready to create custom UI experiences across Salesforce using Lightning types.